Search code examples
emailgrailsexchange-servergrails-pluginexchange-server-2007

Grails mail plugin configuration for MS Exchange server


I am able to send email using my gmail account from my grails application but when I use MS exchange server account I am getting this error

Message: Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.exg6.exghost.com/, 25; timeout -1;

Configuration I used is :

mail {
      host = "smtp.exg6.exghost.com"
      port = 25
      username = "xxxx"
      password = "xxxx"
      props = ["mail.smtp.auth":"true",
               "mail.smtp.socketFactory.port":"25",
               "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
               "mail.smtp.socketFactory.fallback":"false"]

I am not sure what configuration to use. I tried changing port to 465 & 993 but that didn't work too. Please help


Solution

  • I finally got this working. Turns out Microsoft provide a separate API / web-services to send email and perform all other mail related operations. This API gives developers programmatic access to Exchange Online, Exchange Online as part of Office 365, and versions of Exchange starting with Exchange Server 2007 Service Pack 1 (SP1). Click here for details.

    exg6.exghost.com is host for Exchange Server 2007

    And I am not sure but I think Exchange server 2007 and onwards don't use SMTP.