Sending Mail using Jenkins Plugin (Linux based)

Ashish Kumar
LinuxWorld Informatics Pvt. Ltd.
3 min readMay 15, 2020

This article will guide you on how to send email using the plugins available in Jenkins. I will be using Gmail as the mail server here.

Settings to be done Google Account settings

Also, make sure, 2 Step Verification is switched off.

Now, moving on to Jenkins and configuring it.

  1. Installing the required plugins.

** Every plugin installed has its own use cases. The main plugin is marked in red.

2. Changes in the Jenkins configuration file

Open /etc/sysconfig/jenkins and edit JENKINS_JAVA_OPTIONS as follows ::

JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true -Dmail.smtp.ssl.protocols=TLSv1.2"

and restart Jenkins service

sudo service jenkins restart

3. Configuring the plugin

** TLS is the successor of SSL so we will be using it here.

** All the plugins need to be configured separately. I will be showing you a basic setup of one of the plugins and the same can be followed for all.

If using SSL instead of TLS, then use port 465.

Please make sure either your firewall is off or the ports are allowed through firewalld.

SMTP Server: Server to be used for mailing service. I have used the Gmail server. You can set your accordingly.

Reply-to-address: If you don’t want any queries on the server mail, then provide this so any reply to this mail will go to that email id.

Verifying the configuration

Tested and running successfully.

4. Using the plugins

These plugins can be found in post-build actions and can be used as per the requirement. For example, E-mail notification gives you just two options i.e. sending mail for unstable builds and emails to the devs who broke the build. Recipients can be set accordingly.

The other two notification plugins provide more elaborate features.

I hope this helped. You can appreciate by giving us an applaud.

Worked in collaboration with Daksh Jain.

Connect me on my LinkedIn as well.

--

--

Ashish Kumar
LinuxWorld Informatics Pvt. Ltd.

Just a tech enthusiast… Research, implement and share is what I like to do