A Step-by-Step Guide to Configuring SMTP in Jenkins with Gmail

Madhan Chinnasamy
4 min readAug 6, 2023

Introduction:

Jenkins is a popular automation server that provides powerful features for continuous integration and delivery. One essential functionality is the ability to send email notifications to keep users informed about build statuses and other important events. In this blog post, we will explore in detail how to configure the Simple Mail Transfer Protocol (SMTP) in Jenkins to work with Gmail, enabling seamless email notifications from your Jenkins server.

By following this detailed guide, you can successfully configure SMTP in Jenkins with Gmail and enhance your continuous integration and delivery pipeline with informative email notifications.

Table of Contents:

1. Prerequisites

2. Configuring Gmail SMTP Access

3. Jenkins SMTP Configuration

3.1. Installing the Email Extension Plugin

3.2. SMTP Server Configuration

3.3. Testing the Configuration

4. Troubleshooting Common Issues

4.1. Authentication Failure

4.2. Connection Timeout Issues

5. Conclusion

1. Prerequisites:

Before we begin, make sure you have the following prerequisites in place:

- A working Jenkins server.

- A Gmail account with SMTP access enabled.

- Gmail account credentials (username and password).

2. Configuring Gmail SMTP Access:

To allow Jenkins to send emails using your Gmail account, you need to enable SMTP access in your Gmail settings.

Generate Password from Gmail

Go to “https://myaccount.google.com/” and Click “Security”

Then Click on “2-Step Verification

Then click “App password

Select “Mail” and “Windows Computer” from the Dropdown and Click “Generate”

It will generate password.

3. Jenkins SMTP Configuration:

3.1. Installing the Email Extension Plugin:

Access your Jenkins server and navigate to the “Manage Jenkins” section. Select “Manage Plugins” and install the “Email Extension Plugin.” Restart Jenkins if prompted.

3.2. SMTP Server Configuration:

In the Jenkins configuration settings, locate the “Extended E-mail Notification” section. Fill in the following details:

- SMTP Server: Enter “smtp.gmail.com” as the SMTP server address.

- Use SMTP Authentication: Enable this option.

- SMTP Username and Password: Provide your Gmail account credentials.

- Advanced options: Set the port to 465, enable SSL/TLS, and configure other settings as needed.

3.3. Testing the Configuration:

To ensure the SMTP configuration is correct, click the “Test Configuration” button in the Jenkins email notification settings. This will send a test email to the specified recipient address. Verify that the test email is successfully delivered.

Check the Gmail Inbox You will receive a Test email

4. Troubleshooting Common Issues:

This section addresses common issues you may encounter during the SMTP configuration process and provides troubleshooting steps to resolve them.

4.1. Authentication Failure:

If SMTP authentication fails, double-check the SMTP username and password entered in Jenkins. Ensure they match your Gmail account credentials and that you have enabled SMTP access for your Gmail account.

4.2. Connection Timeout Issues:

If you experience connection timeout issues, verify that the SMTP server address and port are correctly configured. Additionally, check your network/firewall settings to ensure they allow outgoing SMTP connections to Gmail’s servers.

5. Conclusion:

Configuring SMTP in Jenkins with Gmail opens up the ability to send reliable email notifications for build statuses and other critical events. By following the steps outlined in this guide, you can seamlessly integrate Jenkins with your Gmail account, ensuring efficient communication throughout your CI/CD processes.

Note:

Remember to regularly test your SMTP configuration and stay updated with any changes in Gmail’s SMTP settings or Jenkins to maintain a smooth email notification workflow.

--

--

Madhan Chinnasamy

Devops Enthusiast- Beginner level knowledge on AWS | Linux | Jenkins | Github | Terraform | Ansible | Docker