2015-07-12 90 views
0

我使用基於Java的CMS dotCMS,我想使用谷歌作爲smtp服務器。我使用了dotCMS文檔中描述的配置:http://dotcms.com/docs/latest/mail-configurationSTARTTLS問題當使用谷歌作爲smtp服務器時,使用javamail

我的配置是這樣的:

<Resource 
      name="mail/MailSession" 
      auth="Container" 
      type="javax.mail.Session" 
      mail.debug="true" 
      mail.transport.protocol="smtp" 
      mail.smtp.host="smtp.gmail.com" 
      mail.smtp.auth="true" 
      mail.smtp.port="465" 
      mail.smtp.starttls.enable="true" 
      mail.smtp.user="[my username]" 
      mail.password="[my pwd]" 
      username="[my username]" 
      password="[my pwd]" 
      mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory" 
    /> 

當我打電話$mailer.sendEmail方法我得到一個錯誤回來:

「無法發送消息:530 5.7.0必須首先發出STARTTLS命令。 c7sm25357283wjb.19 - gsmtp「。

我也嘗試過端口587,但這也沒有幫助。

任何想法我做錯了什麼?我正在使用dotcms 2.5.6。在debian 7.8上運行(wheezy)

回答

2

你不應該需要socketFactory setting

您也不應該需要端口設置。

嘗試設置mail.smtp.ssl.enable = true。如果這不起作用,請嘗試設置mail.transport.protocol = smtps並將所有mail.smtp。*設置更改爲mail.smtps。*。

Gmail entry in the JavaMail FAQ可能是有用的。

如果這些都不起作用,請發佈JavaMail調試輸出。

+0

嘿比爾。謝謝你的提示。我會測試一下。 – koenpeters

1

你有在谷歌設置2因素認證?我認爲這可能會阻止身份驗證的發生。

相關問題