Java 在play 2.0中发送电子邮件异常

Java 在play 2.0中发送电子邮件异常,java,playframework,playframework-2.0,Java,Playframework,Playframework 2.0,我正在为一个项目使用Play2.0,我正在尝试向用户发送电子邮件。我使用这个插件[https://github.com/typesafehub/play-plugins/tree/master/mailer] 在我的Build.scala中,我添加了 "com.typesafe" %% "play-plugins-mailer" % "2.0.4" 在conf/play.plugins中 1500:com.typesafe.plugin.CommonsMailerPlugin 在我的c

我正在为一个项目使用Play2.0,我正在尝试向用户发送电子邮件。我使用这个插件[https://github.com/typesafehub/play-plugins/tree/master/mailer]

在我的Build.scala中,我添加了

 "com.typesafe" %% "play-plugins-mailer" % "2.0.4" 
在conf/play.plugins中

 1500:com.typesafe.plugin.CommonsMailerPlugin
在我的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"
我的控制器操作是

 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();
 }
我得到以下错误

[EmailException: Sending the email to the following server failed : smtp.gmail.com:25]
我做错了什么。我们将非常感谢您的帮助


谢谢

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"

在这上面浪费了一个小时,这很有效:

smtp.user="test@gmail.com"
smtp.password="xxxxxxx"
smtp.user不是smtp.username