Roam
Roam

Reputation: 371

Jenkins Email sending fails

I set up the JENKINS Editable Email notification for my project with trigger for all builds.

the build runs successfully but the emails does not send. The follwing is the result in the console output.

BUILD SUCCESSFUL
Total time: 43 seconds
Email was triggered for: Always
Sending email for trigger: Always
Sending email to: chauhanheena@gmail.com
Connection error sending email, retrying once more in 10 seconds...
Connection error sending email, retrying once more in 10 seconds...
Failed after second try sending email
Finished: SUCCESS

Upvotes: 37

Views: 64917

Answers (8)

bluelights
bluelights

Reputation: 1306

Since I don't know the error log of your issue, I will try to give what worked for me. I tried everything else but the below step saved me. Hope it will help someone with the similar issue.

I just set the System Admin e-mail address correctly.

here are detailed steps:

Try this out and test again to send:

  1. These steps are already given in other solutions but still writing down here for completeness: Fill up SMTP server, set Default user e-mail suffix as @somedomain.com, check Use SMTP Authentication, put username and password, check Use SSL, set SMTP Port, set Charset to UTF-8.
  2. Open: Manage Jenkins > Configure System
  3. Find Jenkins Location option
  4. Fill the System Admin e-mail address like this:

    your-name <email-id@somedomain.com>

  5. Try sending test email again.

Upvotes: 2

You_Shall_Not_Pass
You_Shall_Not_Pass

Reputation: 332

A little late to the party but here's how I made it work in my case. I was trying to authenticate the credentials with AWS SES.

TLDR: Try a different SMTP Port. Changing the port from 587 to 465 allowed Jenkins to authenticate with AWS SES.

And for those who are curious. Here's how I figured out what the issue was.

Go to following location.

Jenkins > Manage Jenkins > Configure System

Scroll down until you find the following option to Enable Debug Mode. See below.

Enable Debug mode

And after enabling the debug mode, the console output became a lot more detailed and I could see the below at the very end.

Console Output of the build

Changing the SMTP Port allowed Jenkins to go through. SES allows the following ports.

Port: 25, 465 or 587

Hopefully that should fix the issue and allow emails to flow though. Or else the the debug mode might steer you in the right direction.

EDIT: Important

The email I was trying to send was from the Editable Email Notification section.

Jenkins > Project $Project_Name > Configure > Post Build Actions > Add Post Build Action > Editable Email Notification.

Upvotes: 6

Nilanjan Mondal
Nilanjan Mondal

Reputation: 61

I was also facing the same issue but again i revisit below things and it worked.

First make sure email notification related plugins are installed (Manage Jenkins->Manage Plugins->Check if email related plugins are
installed or not)

Then Go to Configure System(Manage
Jenkins->Configure system) and navigate to Extended E-mail
Notification section and provide

  • SMTP server-smtp.gmail.com
  • Check -Use SMTP Authentication
  • Provide User name (say your gmail)and corresponding password( Email address from where email will trigger upon completion of build,Note -you need to turn on allow option for secure app to sign in from gmail settings)
  • USe SSL-cheked
  • SMTP Port-465
  • Add your gmail in Reply to list also.
  • In E-mail Notification also provide - smtp.gmail.com

Save above all.

Now all you need to do is to set up post build section - Open ur project and in post build section( From your Projecct click on configure), provide desire email address(to whom you want to send the email) on Recipients field of Email Notification/Editable Email Notification field Now go ahead with build now.

Upvotes: 6

Pankaj Shinde
Pankaj Shinde

Reputation: 3689

You should set SMTP Server and Authentication in both E-mail Notification and Extended E-mail Notification sections. Click Advanced button to see this Use SMTP Authentication section.

If issue still persists, then just restart jenkins, it will work. Somehow the Jenkins system was unable to load all of the configs?

Upvotes: 10

Colin Q
Colin Q

Reputation: 91

Under Manage Jenkins -> Configure System: fill in the section "Extended E-mail Notification" as per your "E-mail Notification" section. That should work.

Upvotes: 0

Brother
Brother

Reputation: 2220

I was having the same issue, and the only way I could send emails was using mail:

mail(
        bcc: '',
        body: "<p>your body</p>",
        cc: '',
        charset: 'UTF-8',
        from: '',
        mimeType: 'text/html',
        replyTo: '',
        subject: "your subject",
        to: "your-email@mail.com"
)

Upvotes: 3

diidu
diidu

Reputation: 2863

Make sure SMTP server is configured under "Manage Jenkins" -> "Configure System" -> "Extended E-mail Notification"

Note also that depending on your plug-in set up, you may have another place to configure SMTP server. For example under "Manage Jenkins" -> "Configure System" -> "E-mail Notification".

That is not needed for this particular plug-in but it may lead you think you have everything done, while it is not :)

Upvotes: 56

JasonRobinson
JasonRobinson

Reputation: 107

Does your Jenkins Config have an SMTP server set up correctly? Have you tested the config with a test email?

Go to "Manage Jenkins" -> "Configure System" and scroll to the bottom to make sure these are set up correctly.

If you servlet container server doesn't have an SMTP server, then you need to find whatever your Outlook is connected to, and see if you can use that. You may need to provide credentials for authentication depending on the server's setup.

Upvotes: 0

Related Questions