7

I'm trying to configure mail with an Exchange server.

This is my configuration

grails {
    mail {
        host = "mail.xxx.xx.xx"
        port = 443
        username = "username"
        password = "password"
        props = [   "mail.smtp.auth":"true",
                    "mail.smtp.port":"443",
                    "mail.smtp.ssl.enable" :"true"
                 ]
    }
}

I'm getting the following error

Message: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
  nested exception is:
    java.net.SocketException: Connection reset. Failed messages: javax.mail.MessagingException: Exception reading response;

I know it's an issue with the props that I have to change, since this configuration works on my mail app. I know that the port is correct, it uses SSL.

I also tried using these props

    props = ["mail.smtp.timeout"               : "100000",
             "mail.smtp.starttls.enable"       : "true",
             "mail.smtp.EnableSSL.enable"      : "true",
             "mail.transport.protocol"         : "smtps",
             "mail.smtp.socketFactory.port"    : "443",
             "mail.smtp.auth"                  : "true",
             "mail.smtp.socketFactory.class"   : "javax.net.ssl.SSLSocketFactory",
             "mail.smtp.socketFactory.fallback": "false",
             "mail.debug"                      : "true"]

The debug result it this :

DEBUG: JavaMail version 1.5.1
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "xxx.xxx.xx.xx", port 443, isSSL true
Dany Y
  • 6,833
  • 6
  • 46
  • 83

2 Answers2

0

It looks to me as a certificate problem. If you have access to a server not using SSL, I would test that first, otherwise you should:

Community
  • 1
  • 1
esauro
  • 1,276
  • 10
  • 17
  • Hi tried it, it's not a certificate issue, because i have it. – Dany Y May 27 '15 at 09:55
  • Uhm, are you sure your port is 443? Normally that port is used by secure web servers. The standard port for secure smtp is 465. – esauro May 28 '15 at 08:11
0

I had the very same issue a while back. If you are trying to access an exchange server within a network (organization), I believe the port number is the issue here. It could have been changed by the network admin.

Please contact the network administrator and explain to him that you are trying to access the Exchange Server and require the username, password and the relevant port number. Authentication could be optional if the app is run in-house, i.e.

props = ["mail.smtp.auth":"false"]

I hope this helps.

vivwilfer
  • 174
  • 4