I have a grails 2.2.1 app with mail plugin 1.0.1.
Mail delivery via Gmail smtp server works fine when I run the app locally (grails dev run-app), but fails on the production server (which is on the Jelastic cloud platform), which I deploy as a war file.
Config.groovy:
// Mail
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "aut********@gmail.com" // *** = just blacked out
password = "sun1******" // *** = just blacked out
props = ["mail.smtp.auth":"true",
"mail.smtp.starttls.required": "false",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
But I only have one mail plugin configuration, and therefore assume that the config applies for both development and production environment.
In fact, when I unzip the war file and check the class (in my case: Config$_run_closure2_closure8_closure13.class) via Decompiler, I can see the correct config values in there:
Enlarged: http://i.troll.ws/638ef33d.png
Error message:
Caused by: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 d47sm23030880eem.9 - gsmtp
at grails.plugin.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:104)
at grails.plugin.mail.MailService.sendMail(MailService.groovy:41)
at MailGrailsPlugin$_configureSendMail_closure6.doCall(MailGrailsPlugin.groovy:170)
at com.oritrack.core.ApiController.register(ApiController.groovy:212)
... 5 more
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 d47sm23030880eem.9 - gsmtp
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:648)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)
at javax.mail.Service.connect(Service.java:291)
... 9 more
It is so weird that the authentication fails; so it's at least trying to connect to the right server; and the username/password in the Config.groovy is the only set of mail plugin config that I have in there. If it runs locally, it gotta run elsewhere.