SocketTimeoutException when sending email With STARTTLS

Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.

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.

*Except Fisheye and Crucible

Problem

When sending a test email via an STARTTLS connection mail won't be sent and the following error message is displayed:

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

The following appears in the atlassian-confluence.log

1 2 3 4 5 6 7 An error has occurred with sending the test email: com.atlassian.mail.MailException: javax.mail.MessagingException: Exception reading response; nested exception is: java.net.SocketTimeoutException: Read timed out at com.atlassian.confluence.jmx.JmxSMTPMailServer.doSendWithMessageIdSupport(JmxSMTPMailServer.java:143) at com.atlassian.confluence.jmx.JmxSMTPMailServer.send(JmxSMTPMailServer.java:88) at com.atlassian.confluence.admin.actions.mail.SendTestEmailAction.execute(SendTestEmailAction.java:60)

Diagnosis

Environment

If you unsure you had STARTTLS mail server or SSL mail server, you can you below's tool to identify it

http://www.checktls.com/perl/TestReceiver.pl

Resolution

Since STARTTLS upgrades the connection to TLS after it has been established, the standard way of retrieving SSL certificates will not work.

Additional argument "-starttls smtp" is required in the openssl call.

1 2 openssl s_client -debug -connect mail.mycompany.com:587 -starttls smtp < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt jre/bin/keytool -import -alias tomcat -keystore jre/lib/security/cacerts -file public.crt

ℹ️ Standard certificate store password is "changeit".

Repeating this for all required certificates

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.