danday74
danday74

Reputation: 56936

Jenkins email could not connect failure

I have tried with various SMTP servers but I cannot get Jenkins to send an email. I get the could not connect error - nothing else, just this error.

See the screenshot below.

Any ideas why? I am using the Jenkins docker container, firewall is off.

I do not have an email server running inside the Jenkins container. I figure I don't need one if Gmail is going to send the email for me.

Image of stack trace from SMTP handler in Jenkins UI

Upvotes: 5

Views: 678

Answers (2)

danday74
danday74

Reputation: 56936

UNBELIEVABLE. 2 days later. Fixed.

I found that my Cloud computing provider (Scaleway) disable outgoing SMTP by default and I had to enable SMTP via their web interface. Details here.

These commands helped me to determine that outgoing SMTP was in fact as dead as a donut:

telnet smtp.gmail.com 465

openssl s_client -connect smtp.gmail.com:587 -starttls smtp

echo "Hello world" | swaks -4 --server smtp.gmail.com:587 --from [email protected] --to [email protected] -tls --tls-protocol sslv3 --auth PLAIN --auth-user [email protected] --auth-password 7654321 --h-Subject "Test message" --body -

Upvotes: 1

lax1089
lax1089

Reputation: 3473

Your Gmail configuration looks correct. Usually these issues come down to a firewall, but if you are sure that is not the problem it could be your Gmail account settings.

An additional configuration is required in the Gmail account from which the mail is being triggered. This step authorizes apps like Jenkins to use the Gmail account.

Gmail - Allowing less secure apps to access your account

After performing this step emails should be triggered successfully.

Upvotes: 1

Related Questions