Friday, August 26, 2016

Jenkins – SMTP setup

There is always a need for getting the Status of the nightly Build that we configure. Jenkins does provide a Email Notification option which allows us to configure Email Notifications that can be used to get the status of the Build. In this article we will see how we can configure the SMTP Configuration in Jenkins and get a mail for the Failed Build.

1. Configure the SMTP Setup
Configure System -> Email Notification ( Enter the Values accordingly )

SMTP Server – (Click Advanced)
Check “Use SMTP Authentication”

User Name –Mail ID you want to Send mail from
Password – Enter the Password for the above configured Mail ID
SMTP Port – 587
Reply-To- Address – Same above mail
Charset – UTF-8

Check the Test Configuration by sending a test E-mail, it will send a test email.

Note – At this moment there may be case where we see some errors saying

a) Must Issue a STARTLS Command first.

For this Error, please add the startls command to the JAVA Command line that start Jenkins. For me the Jenkins file is located at “/etc/sysconfig/Jenkins”

Add the “-Dmail.smtp.starttls.enable='true'” to the existing JENKINS_JAVA_OPTSIONS variable as

JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable='true'"

b) javax.mail.AuthenticationFailedException: 534-5.7.14 <

If the above error, comes login to you Gmail account that you want to send mail and browse the below link ““

Click the “Turn ON” Check box and error will go off.

This feature is disabled to block less secure apps from accessing Google Apps accounts

2) Once the SMTP configuration is success, we now need to configure email settings for the Build Job. Click the build job and in the Build Setting , check the Email Notification.

Enter the Recipients main in the Recipients Box and Check the “Send e-mail for every unstable build”

This will make sure that for every failed build a mail alert is sent to the people in the Recipients list.
That’s all you need to do for configuring the Mail alerts in Jenkins. More to Come. Happy Coding.

1 comment :