【问题标题】:Sending email exception in play 2.0在 play 2.0 中发送电子邮件异常
【发布时间】:2013-02-05 19:07:00
【问题描述】:

我正在为一个项目使用 play 2.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]

我做错了什么。任何帮助将不胜感激。

谢谢

【问题讨论】:

    标签: java playframework playframework-2.0


    【解决方案1】:

    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"
    

    【讨论】:

      【解决方案2】:

      刚刚浪费了一个小时,这很有效:

      smtp.user="test@gmail.com"
      smtp.password="xxxxxxx"
      

      smtp.user 不是 smtp.username

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-11-28
        • 1970-01-01
        • 2020-03-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-17
        相关资源
        最近更新 更多