How to configure mail server in jenkins
Configuring a mail server in Jenkins allows you to receive notifications about job builds, failures, and other events. Here's a step-by-step guide on how to configure a mail server in Jenkins:
Prerequisites:
- You have a Jenkins instance set up and running.
- You have a mail server (e.g., Gmail, Outlook, or a self-hosted mail server) with a valid email account and password.
Step 1: Configure Jenkins to use a mail server
- Log in to your Jenkins instance and navigate to the Configure Jenkins page (usually found under Manage Jenkins > Configure Jenkins).
- Scroll down to the Email Notification section.
- Click on the Advanced button next to Email Notification.
- In the Email Notification page, select the Send emails checkbox.
- Enter the following details:
- SMTP Server: The hostname or IP address of your mail server (e.g.,
smtp.gmail.com
for Gmail). - SMTP Port: The port number used by your mail server (e.g.,
587
for Gmail). - Username: Your email account username (e.g., your Gmail address).
- Password: Your email account password.
- Use SSL: Select this checkbox if your mail server uses SSL/TLS encryption.
- SMTP Server: The hostname or IP address of your mail server (e.g.,
- Click Save to save your changes.
Step 2: Configure email notifications for specific jobs
- Navigate to the Configure page for a specific job (e.g., Job Name > Configure).
- Scroll down to the Post-build Actions section.
- Click on the Add post-build action dropdown menu and select Email notification.
- Configure the email notification settings as desired (e.g., specify the recipients, subject, and body).
- Click Save to save your changes.
Additional tips:
- Make sure to enable Less secure apps in your Google account settings if you're using Gmail as your mail server.
- If you're using a self-hosted mail server, ensure that it's configured to allow incoming connections from Jenkins.
- You can also configure email notifications for specific events, such as build failures or successful builds, by using the Email notification plugin in Jenkins.
By following these steps, you should be able to configure a mail server in Jenkins and receive notifications about job builds and other events.