I am trying to configure mail on 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 get 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 that this is a problem with props, which I have to change, since this configuration works in my mail application. I know that the port is correct, it uses SSL.
I also tried to use these details
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"]
Debugging will result in the following:
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