To be able to send emails in Jenkins we have to do two things:
Setup SMTP server in global settings and set the notification option in the project.

To set SMTP server:

  • go to Manage Jenkins -> Global Settings
  • SMTP server (i.e., outgoing mail): smtp.gmail.com
  • SMTP username: Your full Gmail or Google Apps email address (e.g. example@gmail.com or example@yourdomain.com)
  • SMTP password: Your Gmail or Google Apps email password – be aware if you have a 2-Step Verification, you have to generate a code for the setup
  • SMTP port: 465
  • SMTP TLS/SSL required: yes

2015-10-13_2252[1]

To test your configuration:

  • Tick the Test configuration by sending test e-mail checkbox
  • Write an email address to the Test e-mail recipient
  • Click Test configuration

If you have everything correctly configured the test email should arrive to the specified address. The next step is to set up the email notification for the project.

  • Select your project from the Jenkins main menu screen

2015-10-13_2238[1]

  • Click on the post build action in the configuration
  • Choose “Email Notification”
  • Set the Recipients
  • For lazy projects where unstable builds are the norm, Uncheck “Send e-mail for every unstable build”.
  • Click Save

2015-10-13_2253[1]

Now everything is set up. Whenever your build is broken you should get an email notification.

Similar Posts from the author: