Jenkins Email sending fails
Asked Answered
C

8

37

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: [email protected]
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
Conroy answered 12/5, 2015 at 8:49 Comment(0)
H
56

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 :)

Hartwig answered 15/6, 2015 at 9:35 Comment(1)
This was exactly my issue - I didn't realize that, with the email-ext plugin installed, there are two SMTP server fields when configuring jenkins!Velodrome
M
10

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?

Megmega answered 16/8, 2018 at 7:24 Comment(1)
Good old reboot... Solved it for me! +1Belldame
C
6

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.

Clift answered 7/11, 2018 at 20:8 Comment(0)
B
6

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.

Badger answered 27/9, 2019 at 15:25 Comment(0)
F
3

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: "[email protected]"
)
Frozen answered 10/7, 2018 at 14:45 Comment(1)
This is what I ended up doing, and it worked after I specified a nonempty "from" field.Paw
R
2

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 protected]>

  5. Try sending test email again.
Radionuclide answered 29/6, 2021 at 3:59 Comment(1)
Step 4 is the one which is crucial.Suzy
T
0

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.

Talion answered 13/5, 2015 at 23:21 Comment(0)
L
0

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

Lastditch answered 24/7, 2018 at 6:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.