試圖在application.conf
heroku玩!與sendgrid配置
mail.smtp.host=smtp.sendgrid.net
mail.smtp.user=${SENDGRID_USERNAME}
mail.smtp.pass=${SENDGRID_PASSWORD}
和Controller
MultiPartEmail email = new MultiPartEmail();
//... setting from,to,subject,content...
Mail.send(email); //using Play's util
但異常發生時配置SMTP,認證的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
這是'git push'時間的錯誤嗎?如果是這樣,你可以忽略它。你是否收到'Mail.send()'的異常? – 2012-02-17 20:08:21
'git push'沒有錯誤,只是警告。 「Mail.send()」例外是來自不良用戶憑證。我試過,如果我直接在代碼中使用'System.getenv(「SENDGRID_USERNAME」)'並使用'MultipartEmail'的'send',它可以發送。但在這種情況下,我無法使用內置的郵件模擬器進行本地測試。 – jackysee 2012-02-18 23:49:25