0
0
JenkinsHow-ToBeginner · 4 min read

How to Configure SMTP in Jenkins for Email Notifications

To configure SMTP in Jenkins, go to Manage Jenkins > Configure System, then find the E-mail Notification section. Enter your SMTP server details like SMTP server address, port, and credentials, then save the settings to enable Jenkins to send emails.
📐

Syntax

In Jenkins, SMTP configuration is done through the web interface under Manage Jenkins > Configure System. The key fields are:

  • SMTP server: The address of your mail server (e.g., smtp.gmail.com).
  • Default user e-mail suffix: Optional domain suffix for email addresses.
  • Use SMTP Authentication: Enable if your SMTP server requires login.
  • User Name and Password: Credentials for SMTP authentication.
  • Use SSL: Enable if your SMTP server requires a secure connection.
  • SMTP port: Usually 25, 465, or 587 depending on your server.
text
SMTP Server: smtp.example.com
Default user e-mail suffix: @example.com
Use SMTP Authentication: true
User Name: your-email@example.com
Password: your-password
Use SSL: true
SMTP Port: 465
💻

Example

This example shows how to configure Jenkins to send emails using Gmail's SMTP server.

text
SMTP Server: smtp.gmail.com
Default user e-mail suffix: @gmail.com
Use SMTP Authentication: true
User Name: your-email@gmail.com
Password: your-app-password
Use SSL: true
SMTP Port: 465
Output
Settings saved successfully. Jenkins can now send emails via Gmail SMTP.
⚠️

Common Pitfalls

Common mistakes when configuring SMTP in Jenkins include:

  • Using incorrect SMTP server address or port.
  • Not enabling SMTP authentication when required.
  • Using the wrong password or not using an app-specific password for services like Gmail.
  • Not enabling SSL/TLS when the SMTP server requires it.
  • Firewall blocking SMTP ports.

Always test your configuration by sending a test email from Jenkins after setup.

text
Wrong way:
SMTP Server: smtp.gmail.com
Use SMTP Authentication: false

Right way:
SMTP Server: smtp.gmail.com
Use SMTP Authentication: true
User Name: your-email@gmail.com
Password: your-app-password
Use SSL: true
SMTP Port: 465
📊

Quick Reference

SettingDescriptionExample
SMTP ServerMail server addresssmtp.gmail.com
SMTP PortPort number for SMTP465 or 587
Use SMTP AuthenticationEnable login for SMTPtrue
User NameEmail login usernameyour-email@gmail.com
PasswordEmail login password or app passwordyour-app-password
Use SSLEnable secure connectiontrue

Key Takeaways

Configure SMTP in Jenkins under Manage Jenkins > Configure System > E-mail Notification.
Use correct SMTP server, port, and authentication settings for your mail provider.
Enable SSL if your SMTP server requires a secure connection.
Use app-specific passwords for services like Gmail instead of your main password.
Always test email sending after configuration to confirm settings work.