2014-04-11 126 views
0

我使用下面的conf通過play-easymail在播放v2.2中發送電子郵件 - 我沒有看到任何異常拋出我的代碼&我已經嘗試了本地SMTP服務器以及來自gmail的SMTP服務。我無法收到電子郵件(不在任何垃圾郵件文件夾中)。有關解決此問題的任何建議(除了檢查本地SMTP服務器日誌),將不勝感激。 SMTP配置通過application.config文件導入。問題與播放easymail使用播放框架2.2

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 
    [email protected]" 

    # 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(); 
} 

回答

0

它是導頻誤差。我必須在conf文件中將模擬設置爲false。在發生這種變化之後,我能夠發送電子郵件。

mock=false