Confluence unable to send email through Gmail server due to 'SocketTimeoutException: Read timed out'

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Cloud および Data Center - この記事はクラウドと Data Center 両方のプラットフォームに等しく適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

問題

Confluence fails to send email.

診断

atlassian-confluence.log に次のメッセージが出力される。

com.atlassian.mail.MailException: javax.mail.MessagingException: Exception reading response;
  nested exception is:
	java.net.SocketTimeoutException: Read timed out

原因

Confluence is configured to use a port other than 587 to connect to the Gmail server

ソリューション

Confluence 5.6 以降

For Confluence 5.6 and above, you can set up Gmail through the admin console

  1. Go to Admin > Mail Servers
  2. Click 'Add a new SMTP mail server'
  3. Fill out your mail account details. 
  4. Enter smtp.gmail.com for the mail server and 587 for the port, and ensure you tick Use TLS:

Confluence 5.5.x and below

For Confluence 5.5.x and below, you will need to create a JNDI mail session and then have Confluence use it, as described below.

To do this for the Confluence distribution, please see Setting Up a Mail Session for the Confluence Distribution.

  1. Confluence を停止します。
  2. Move (don't copy) activation-1.0.2.jar (if it exists) and mail-1.4.1.jar from /confluence/WEB-INF/lib to <Confluence Standalone install>/lib. Or if you are using Confluence WAR release, move to <Tomcat 5 install>/common/lib or <Tomcat 6 install>/lib.

    The exact version numbers on these jar files may vary, but that should not matter. As of Confluence 5.2.3, activation-1.0.2.jar no longer exists, and does not need to be moved or downloaded

    Do not leave a renamed backup of the jar files in /confluence/WEB-INF/lib. Even with a different file name, the files will still be loaded as long as it remains in the directory.

  3. Add the following Resource tag in confluence.xml or server.xml located at <confluence-install>/conf, inside the <Context> node (substituting username and password), so it looks like this:

    Server.xml
    // The context tag here is for illustrative purposes only, to highlight where the Resource tag should be entered. You do not need to copy the Context tag, it will already exist in your file.
    <Context path="/confluence" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true">
        <!-- Logger is deprecated in Tomcat 5.5. Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties -->
        <Manager pathname="" />
     
    	// Copy this Resource tag into the Context tag in your server.xml, and enter your user and password details
        <Resource name="mail/Session"
            auth="Container"
            type="javax.mail.Session"
            mail.smtp.host="smtp.gmail.com"
            mail.smtp.port="465"
            mail.smtp.auth="true"
            mail.smtp.user="nobody@gmail.com"
            password="foobar"
            mail.smtp.starttls.enable="true"
            mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
        />
    	// End section to copy
    </Context>
  4. Confluence インスタンスを再起動します
  5. Add java:comp/env/mail/Session to your JNDI mail configuration from Administration > Mail Servers.

メモ:

  • You may optionally add mail.debug="true" into the <Resource> to see logs generated by JavaMail.
  • If your Google account uses 2-step verification you will need to use an application password instead of your password.
  • Also, if you find connection errors using the port 465 please change it to 587.


最終更新日: 2024 年 12 月 19 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.