我有一个带有邮件插件 1.0.1 的 grails 2.2.1 应用程序。
当我在本地运行应用程序(grails dev run-app)时,通过 Gmail smtp 服务器的邮件传递工作正常,但在生产服务器(位于Jelastic云平台上)上失败,我将其部署为 war 文件。
配置.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"]
}
}
但是我只有一个邮件插件配置,因此假设该配置适用于开发和生产环境。
事实上,当我解压缩war文件并通过反编译器检查类(在我的例子中:Config$_run_closure2_closure8_closure13.class)时,我可以在那里看到正确的配置值:
放大:http: //i.troll.ws/638ef33d.png
错误信息:
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
认证失败太奇怪了;所以它至少在尝试连接到正确的服务器;并且 Config.groovy 中的用户名/密码是我在那里拥有的唯一一组邮件插件配置。如果它在本地运行,它必须在其他地方运行。