试图在里面配置 smtpapplication.conf
mail.smtp.host=smtp.sendgrid.net
mail.smtp.user=${SENDGRID_USERNAME}
mail.smtp.pass=${SENDGRID_PASSWORD}
并且在控制器中
MultiPartEmail email = new MultiPartEmail();
//... setting from,to,subject,content...
Mail.send(email); //using Play's util
但是出现异常,在验证 smtp 服务器时说用户凭据错误。
我注意到的一件事是,当推送到 heroku 并启动应用程序时,它会发出警告:
WARNING: Cannot replace SENDGRID_USERNAME in configuration (mail.smtp.user=${SENDGRID_USERNAME})
WARNING: Cannot replace ENV_SENDGRID_PASSWORD in configuration (mail.smtp.pass=${SENDGRID_PASSWORD})
这可能是由于预编译标志在部署时打开?这是我的Procfile
:
web: play run --http.port=$PORT --%prod