EOF exception during mail due to wrong hostname in EHLO

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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

Summary

Confluence isn't able to send emails and an error message is shown in the user interface (UI) while sending out a test email.

Environment

Confluence server using any SMTP mail server.

Diagnosis

While sending test email, the following error is seen in the UI and the logs.

1 2 3 4 5 6 An error has occurred with sending the test email: com.atlassian.mail.MailException: javax.mail.MessagingException: [EOF] . Caused by: javax.mail.MessagingException: [EOF] at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:2324) at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:1678)

openssl s_client and other network tools like telnet can connect to the mail server properly.

Upon enabling SMTP debug logs we see the following messages.

1 2 3 4 5 6 7 8 9 10 11 DEBUG: JavaMail version 1.6.2 DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle] DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "smtp-relay.mailserver.com", port 587, isSSL false 220 smtp-relay.mailserver.com ESMTP h18sm868180otk.3 - gsmtp DEBUG SMTP: connected to host "smtp-relay.mailserver.com", port: 587 EHLO localhost 421 4.7.0 Try again later, closing connection. (EHLO) h18sm868180otk.3 - gsmtp HELO localhost DEBUG SMTP: EOF: [EOF]

ℹ️ SMTP debug logs can be enabled via system property or setting the property mail.debug="true" in the mail session configuration of Confluence.

Cause

Confluence is presenting itself as localhost to the remote mail server.

1 EHLO localhost

Mail server isn't able to identify Confluence and terminates the connection.

Solution

Confluence should be presenting a valid hostname to identify itself. hostname command in Linux is a good way to check what name comes up. Though, if hostname does return the proper hostname, then the following parameter can be configured in the mail session configuration of Confluence.

1 mail.smtp.localhost="correct_FQDN.com"

Alternatively, we have seen some cases on Linux systems where /etc/hosts contains entries for localhost and the hostname mapping them to 127.0.0.1. On that case, make sure the hostname entry comes first:

1 2 127.0.0.1 localhost 127.0.0.1 <hostname>

Change it to:

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.