0
0
JenkinsHow-ToBeginner · 4 min read

How to Configure Email Notifications in Jenkins Quickly

To configure email in Jenkins, install and enable the Email Extension Plugin, then set SMTP server details in Manage Jenkins > Configure System. Use the Editable Email Notification section to customize email triggers and recipients.
📐

Syntax

Jenkins email configuration involves setting SMTP server details and using the Email Extension plugin to define email notifications in jobs.

  • SMTP Server: The mail server Jenkins uses to send emails.
  • Default User E-mail Suffix: Domain added to usernames if needed.
  • Editable Email Notification: Section to configure email content and triggers per job.
  • Recipients: Email addresses to notify.
  • Triggers: Conditions when emails are sent (e.g., on failure).
text
Manage Jenkins > Configure System > E-mail Notification:
  SMTP server: smtp.example.com
  Use SMTP Authentication: true
  User Name: your-email@example.com
  Password: your-password

Job Configuration > Post-build Actions:
  Add 'Editable Email Notification'
  Recipients: user@example.com
  Triggers: Failure, Success, etc.
💻

Example

This example shows how to configure Jenkins to send an email on build failure using the Email Extension plugin.

text
1. Install 'Email Extension Plugin' from Jenkins Plugin Manager.

2. Go to Manage Jenkins > Configure System.
   - Set SMTP server to smtp.gmail.com
   - Check 'Use SMTP Authentication'
   - Enter your Gmail username and app password
   - Set SMTP port to 587 and enable TLS

3. In your Jenkins job configuration:
   - Add Post-build Action > Editable Email Notification
   - Set 'Project Recipient List' to your email
   - Under 'Triggers', select 'Failure'

4. Save and run the job. On failure, Jenkins sends an email notification.
Output
Jenkins sends an email to the specified recipient when the build fails.
⚠️

Common Pitfalls

  • Not installing the Email Extension Plugin causes missing email options.
  • Incorrect SMTP server or port leads to connection failures.
  • For Gmail SMTP, you must use an app password and enable TLS.
  • Missing recipient emails or wrong trigger settings prevent emails from sending.
  • Firewall or network restrictions can block SMTP connections.
text
Wrong SMTP config example:
SMTP server: smtp.gmail.com
Port: 25 (wrong, should be 587)

Right SMTP config example:
SMTP server: smtp.gmail.com
Port: 587
Use TLS: enabled
📊

Quick Reference

SettingDescriptionExample Value
SMTP ServerMail server Jenkins usessmtp.gmail.com
SMTP PortPort for SMTP connection587
Use AuthenticationEnable login for SMTPtrue
UsernameEmail account usernameyour-email@gmail.com
PasswordEmail account password or app passwordapp-password
TLS/SSLSecure connectionEnabled
RecipientsEmails to notifyuser@example.com
TriggersWhen to send emailsFailure, Success

Key Takeaways

Install and enable the Email Extension Plugin to unlock advanced email features.
Configure SMTP server settings correctly in Manage Jenkins > Configure System.
Set recipients and triggers in job configuration to control when emails send.
Use app passwords and TLS for Gmail SMTP to avoid authentication errors.
Test email settings with a sample job to confirm notifications work.