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:

  1. You have a Jenkins instance set up and running.
  2. 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

  1. Log in to your Jenkins instance and navigate to the Configure Jenkins page (usually found under Manage Jenkins > Configure Jenkins).
  2. Scroll down to the Email Notification section.
  3. Click on the Advanced button next to Email Notification.
  4. In the Email Notification page, select the Send emails checkbox.
  5. 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.
  6. Click Save to save your changes.

Step 2: Configure email notifications for specific jobs

  1. Navigate to the Configure page for a specific job (e.g., Job Name > Configure).
  2. Scroll down to the Post-build Actions section.
  3. Click on the Add post-build action dropdown menu and select Email notification.
  4. Configure the email notification settings as desired (e.g., specify the recipients, subject, and body).
  5. Click Save to save your changes.

Additional tips:

By following these steps, you should be able to configure a mail server in Jenkins and receive notifications about job builds and other events.