Bitbucket Server throws "Unrecognized SSL message, plaintext connection?" when sending test emails
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server 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
Test emails cannot be sent.
The following appears in the atlassian-bitbucket.log:
WARN [<http_thread>] <username> <session_id> <source_ip> "POST /admin/mail-server HTTP/1.1" c.a.s.i.w.a.MailServerConfigurationController Failed to send a test email message to <email_address>
com.atlassian.bitbucket.mail.MailSendException: Mail sending failed. Please verify the mail server configuration and check the logs for details
...
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: <hostname>, port: 587
...
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
Cause
Bitbucket Server is attempting to connect to the mail server via SSL while the mail server is not configured with SSL.
Resolution
- Go to the administration area and click Mail server (under 'Settings')
Select "SMTP" as protocol
- Make sure that "587" or "25" is set as port. Port 465 was previously used for Secure SMTP (SMTPS), but it has now been deprecated.