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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket cannot send mail

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

1 answer

0 votes
Mark A_ Atlassian Team Aug 06, 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

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 Aug 07, 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

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 Aug 08, 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?

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

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.

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 Oct 05, 2020

Same here.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,897 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you