Uma*_*air 4 java playframework playframework-2.0
我正在使用Play 2.0进行项目,我正在尝试向用户发送电子邮件.我使用这个插件[https://github.com/typesafehub/play-plugins/tree/master/mailer].
在我的Build.scala中,我添加了
"com.typesafe" %% "play-plugins-mailer" % "2.0.4"
Run Code Online (Sandbox Code Playgroud)
并在conf/play.plugins中
1500:com.typesafe.plugin.CommonsMailerPlugin
Run Code Online (Sandbox Code Playgroud)
在我的conf/application.conf中,我有设置
smtp.host=smtp.gmail.com
smtp.port=25
smtp.ssl=true
smtp.tls=false
smtp.username="test@gmail.com"
smtp.password="xxxxxxx"
Run Code Online (Sandbox Code Playgroud)
我的控制器动作是
public static Result sendEmail(String recipt, String title, String sender ){
MailerAPI mail = play.Play.application().plugin(MailerPlugin.class).email();
mail.setSubject(SUBJECT);
mail.addRecipient(recipt);
mail.addFrom(sender);
String body = views.html.teams.mailBody.render(recipt, title, sender).body();
mail.sendHtml(body);
return ok();
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
[EmailException: Sending the email to the following server failed : smtp.gmail.com:25]
Run Code Online (Sandbox Code Playgroud)
我做错了什么.任何帮助将受到高度赞赏.
谢谢
Gmail的SMTP配置不同(通过在端口587上启用TLS来保护).
试试这个配置:
smtp.host=smtp.gmail.com
smtp.port=587
smtp.ssl=true
smtp.tls=true
smtp.username="test@gmail.com"
smtp.password="xxxxxxx"
Run Code Online (Sandbox Code Playgroud)