4

プロジェクトに 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]

私が間違っていること。どんな助けでも大歓迎です。

ありがとう

4

2 に答える 2

8

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"
于 2013-01-22T11:09:17.650 に答える
4

これで1時間無駄になりましたが、これはうまくいきました。

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

smtp.usernameではなくsmtp.user

于 2013-02-05T11:07:00.457 に答える