Jenkins build failure emails with Office 365 or Gmail SMTP
Jenkins emails you when builds fail, and pipelines often send their own reports with the Mailer or Email Extension plugins. The Mailer plugin, which provides Jenkins’ standard email settings, signs in with a username and password, so it can’t connect to Microsoft 365 or Gmail, which require OAuth. The Email Extension plugin has an OAuth option, but it needs an access token that you obtain and renew yourself.
With Auth-Email, you change the server, port, and password in Manage Jenkins, and every job and pipeline uses the new settings, with no tokens to manage.
Before you start: link the mailbox in your Auth-Email dashboard, and choose a password for it. That is the password you’ll enter in Jenkins – not your mailbox password.
Step 1: Set Jenkins’ sender address
Jenkins sends email from its System Admin e-mail address. Go to Manage Jenkins > System, and in the Jenkins Location section, set System Admin e-mail address to the linked mailbox’s address (for example, Jenkins <jenkins@yourdomain.com>).
Step 2: Configure email notification
On the same page, in the E-mail Notification section, click Advanced, and enter the following. Show the settings for an account provided by Outlook:
- SMTP server:
outlook.auth-email.com - Use SMTP Authentication: Ticked, with the linked mailbox’s full email address as the User Name, and the password you chose in Auth-Email as the Password
- Use SSL: Ticked
- Use TLS: Unticked
- SMTP Port:
465
Tick Test configuration by sending test e-mail, enter your address, and click Test configuration. Then click Save.
Email Extension plugin
If you use the Email Extension plugin (emailext in pipelines), it has its own settings in the Extended E-mail Notification section of the same page. Enter the same SMTP server and SMTP Port, tick Use SSL, and (under Advanced) add a Username with password credential with the linked mailbox’s address and Auth-Email password in Credentials. Leave Use OAuth 2.0 unticked.
Troubleshooting
- “535 Authentication failed”: check that the username is the full email address, and that the password is the one you chose in Auth-Email (not your mailbox password)
- Timeouts, or “Could not connect to SMTP host”: check that Use SSL is ticked (and Use TLS unticked) with port
465, and that the Jenkins controller can make outgoing connections on that port - “Sender address rejected” or “SendAsDenied”: the System Admin e-mail address (and any from address set in a pipeline) must be the linked mailbox, or an address that the mailbox is allowed to send as
For other errors, such as Microsoft 365 reporting that SMTP AUTH is disabled, see fixing common errors. Your account’s connection page in the Auth-Email dashboard also shows whether Jenkins has connected, and explains any error it received. Still stuck? Email us – we’ll help you get it working.
Related articles
Try Auth-Email with Jenkins
Link your mailbox, update the E-mail Notification settings, and send a test email.
Start your free trial →No credit card needed. Check that it works, including sending yourself test messages, before you pay.