Play Framework 2.2を使用しながらPlay-EasyMailの問題
-
21-12-2019 - |
質問
Play-EasyMailを介してPlay v2.2で電子メールを送信するためのCONFを使用しています。Gmail。私は電子メールを受信できませんでした(迷惑メールフォルダにはありません)。トラブルシューティングに関する提案(ローカルSMTPサーバーログを確認するのに加えて)が理解されます。 smtp configはapplication.configファイルを介してインポートされます。
conf
# SMTP mailer settings
smtp {
# enable mocking - disable this for production
mock=true
# SMTP server
# (mandatory)
# defaults to gmail
host=smtp.gmail.com
# SMTP port
# defaults to 25
port=587
# Use SSL
# for GMail, this should be set to true
ssl=true
#tls=true
# authentication user
# Optional, comment this line if no auth
# defaults to no auth
user=correctEmail@gmail.com"
# authentication password
# Optional, comment this line to leave password blank
# defaults to no password (or use (two way) hash the pwd and get the pwd from the two way hash)
password=correctPwd
}
.
テストコード
import com.feth.play.module.mail.Mailer;
import com.feth.play.module.mail.Mailer.Mail.Body;
//email method: emailAddress passed is correct
try {
final Body body = new Body("test email");
Mailer.getDefaultMailer().sendMail("metrics email | it works!",
body, emailAddress);
}
catch (Exception e) {
Logger.info("exception while sending email {}", e);
e.printStackTrace();
}
. 解決
パイロットエラーでした。私は、confファイル内のfalseに等しいモックを設定しなければなりませんでした。この変更後に電子メールを送信することができました。
mock=false
. 所属していません StackOverflow