Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket cannot send mail

dpliatsios August 4, 2018

Hello all,

I followed this documentation to configure Bitbucket to use gmail as a mailserver, but I get the error "Sending mail failed. Please verify the mail server configuration and check the logs for details".

Bellow you can find a screenshot from the settings:

bitbucket.png

2 answers

0 votes
Emre Oruc
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 8, 2022

Same Problem

0 votes
Mark A_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2018

Hello!

To get started, have you reviewed the atlassian-bitbucket-mail.log for any errors from your attempt to connect? This will be located in your "$BITBUCKET_HOME/log"

Since you are connecting to gmail, have you received any email from Google for your failed login attempt?

We do have a KB article available regarding rejected sign-in attempts with gmail that you can review to see if it applies to your situation.

-Mark

dpliatsios August 7, 2018

Hello,

thank you for the reply. I do not receiving any rejected sign-in errors. It seems that it cannot connect to the server. Bellow you will find the  atlassian-bitbucket-mail.log messages when using ports 465 and 587.

For 465:

ERROR [https-jsse-nio-7443-exec-4] admin @R1DE1Zx722x105x0 7lq14l 84.205.241.5 "POST /admin/mail-server HTTP/1.1" bitbucket.mail-log Sending mail failed. Please verify the mail server configuration and check the logs for details; recipient: pliago@hotmail.com; subject: Bitbucket - Test email for your SMTP configuration
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
...
...
...
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1

 For 587:

ERROR [https-jsse-nio-7443-exec-6] admin @R1DE1Zx723x125x0 7lq14l 84.205.241.5 "POST /admin/mail-server HTTP/1.1" bitbucket.mail-log Sending mail failed. Please verify the mail server configuration and check the logs for details; recipient: pliago@hotmail.com; subject: Bitbucket - Test email for your SMTP configuration
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not convert socket to TLS;
....
....
....
Caused by: javax.mail.MessagingException: Could not convert socket to TLS
...
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Mark A_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 7, 2018

Thanks for the output.

Did you try the steps outlined in the KB article I linked?

- failed sign-in

In the above, you allow less secured apps to connect.

If you have tried the above KB and it fails with the same message, I would attempt to verify that you can actually connect to that port from Bitbucket Server itself by executing one of the following commands:

telnet smtp.gmail.com 465
telnet smtp.gmail.com 587

If it does not connect, then it means that your network is not allowing communication over that port in which I would turn investigation there to ensure firewalls or other routing isn't blocking your request.

-Mark

dpliatsios August 8, 2018

The Allow less secure apps option is enabled on my google account and I can connect through telnet to the smtp server.

I had the same problem with Crowd and was resolved by using JNDI (Here is the question I asked: Crowd cannot communicate with mail server)).

However I cannot seem to find the JNDI option in Bitbucket

Mark A_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 8, 2018

Thanks for the confirmation.

Unfortunately, JNDI configuration is not possible with Bitbucket Server. In my investigation, I found another KB regarding failed mail server configuration with gmail and it states:

Port 465 shows up in Appendix A of the 1996 non-standard The SSL Protocol Version 3.0 as "Simple Mail Transfer Protocol with SSL". Unfortunately, it's not registered for SMTPs. It's registered for URD - "URL Rendezvous Directory for SSL" by Cisco. The recommended approach, at least for authentication, is to use STARTTLS encryption on port 587.

Port 25 can be used but it is for server to relay messages to one another. Port 587 is recommended because this way ISPs can block outgoing SMTP on their networks but still allow users to send email to another mail server.

With this, let's stick with port 587 which gives a different error:

Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

I could not reproduce your issue on port 587 but if we were to look at the error, it would indicate that your certificate truststore couldn't be found, was empty, or could not be opened due to permissions. 

Can you investigate your truststore configuration?

dpliatsios August 9, 2018

I am pretty sure that the security certificate is the issue.

I have done the following steps:

1)I used openssl s_client -connect smtp.gmail.com:465 to export the certificate in a gmail.cert file.

2)I imported the gmail.cert using sudo keytool -import -alias smtp.gmail.com -keystore ~/.keystore -file ./gmail.cert

3)I added the following to the bitbucket.properties file

server.ssl.key-store=/home/dimitris/.keystore
server.ssl.key-store-password=*****
server.ssl.key-password=*****

 However, the problem still remains

George Cosmin Danisor
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 16, 2018

Any update on this issue, I'm having the exact same problem. I managed to get Jira and Bamboo to work by following the tutorial, however when I try to configure Bitbucket I get exactly the same errors as above.

jurgen_schober June 3, 2020

Same here. Difference is, bitbucket runs on Ubuntu 18 LTS with Open JDK 11 and the server is office 365 outlook server. Jira and Bamboo work fine on that server. Any update or reference to another solution? 

TriAset
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 5, 2020

Same here.

Harry Huang August 24, 2021

@dpliatsios  so...Do you have any solution?

Ekaterina Berezutskaya
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 26, 2022

I found the solution. I generated a password and used that passwort in bitbucket mail server settings.

It is described in documentation https://confluence.atlassian.com/bitbucketserverkb/configuring-the-mail-server-to-use-gmail-779171673.html:

Notice that if the Gmail user has 2-step verification enabled, he/she will need to generate a password for an application (in this case Bitbucket Server) and use this application password - not the account password. Please refer to the guide below for more information:

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events