Configure Jenkins Email Notification [3 Easy Steps]

If you configure email notification on Jenkins, Jenkins will notify us about the status of each build via email. Jenkins email notification is a convenient way to track the status of builds. If you configure email notification on Jenkins, you do not need to wait for the build’s results in the Jenkins dashboard results. In this tutorial, we see whether Jenkins Email Notification works and how we can configure Jenkins Email Notification if it does not work.

3 Steps For Jenkins Email Notification

Testing Jenkins Email Notification

First, let’s see how to check if Jenkins can send emails successfully:

Test email from Jenkins

Testing Jenkins Email Notification

Set Who Send the emails

Who send jenkins email notifications

First, we need to set the admin user who send us the emails and its email address. Go to to Manage Jenkins > Configure System. In the Configure System | Jenkins Location fill System Admin e-mail address. The format should be name <email> for example Jenkins <admin@my-jenkines.com>.

Send Test Email

Now, Go to Manage Jenkins > Configure System. In the Configure System | E-mail Notification, Check Test configuration by sending test e-mail checkbox.

A "Test e-mail recipient" text box should appear, Insert an email address to an account you can access. Finally, Press the Test Configuration button. Email was successfully sent appears.

Now, It is time to check that you have received the email.

Check If You Have Received The Email.

Test email from Jenkins

Login your the email account you specified in the previous step. Check if you have an email from the email admin you set in step 1 in your inbox (also check your spam folder). The title of the email should be something like ‘Test email #1’

If you find the email , Jenkins can sent emails successfully. Otherwise, see the how to configure your SMTP server.

Install local SMTP server For Jenkins Email Notification

By default, Jenkins will send emails via the default SMTP server (normally running on localhost). If you do not have an SMTP server already you want to use, you can install SMTP server in your Jenkins machine. To do so, Install mailutils package that provides a SMTP server.

Install SMTP server by installing mailutils package
 root@jenkins:~# ssh my-jenkins
 login as: root
 Authenticating with public key "rsa-key_2016-08-01-jenkins"

 Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-34-generic x86_64)
 ...

 root@jenkins:~# apt-get install mailutils
 ...

Set SMTP Server For Jenkins Email Notification

Now, Go to Manage Jenkins > Configure System. In the Configure System | E-mail Notification and click Advanced button.

Set SMTP Server For Jenkins Email Notification
Set SMTP Server For Jenkins Email Notification

Enter your details of your SMTP server:

  • SMTP server is the domain of the machine. Leave empty for localhost
  • Check Use SMTP Authentication if the server requires authentication and then provide User Name and Password
  • Check use SSL if server requires SSL connection.
  • Provide SMTP port if the port number for the mail server. Leave empty for the default one (25 for simple connection, 465 for SSL connection).

Now, test Jenkins email notification again.

Leave a Reply

Your email address will not be published. Required fields are marked *