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 NameandPassword: 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
| Setting | Description | Example |
|---|---|---|
| SMTP Server | Mail server address | smtp.gmail.com |
| SMTP Port | Port number for SMTP | 465 or 587 |
| Use SMTP Authentication | Enable login for SMTP | true |
| User Name | Email login username | your-email@gmail.com |
| Password | Email login password or app password | your-app-password |
| Use SSL | Enable secure connection | true |
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.