Error "AuthenticationFailedException" while testing Outgoing Mail Server with Oauth 2.0
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
As per Jira 9.2.0 release notes, from Jira 9.2.0 it is possible to configure an Outgoing Mail Server using the Oauth 2.0 by following the instructions from the documentation Configuring an SMTP mail server to send notifications.
After authorizing the mail configuration, and while testing the Connection of the Outgoing Mail Server, either of the 2 errors shown below might be thrown in the UI:
Example of error 1 (in case of a Microsoft Mail Server)
Unfortunately no connection was possible. Review the errors below and rectify: AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [XXXXXXXXXX.XXXXXX.PROD.OUTLOOK.COM]
Example of error 2 (in case of a Google Mail Server)
Unfortunately no connection was possible. Review the errors below and rectify: AuthenticationFailedException: OAUTH2 asked for more
This KB article describes how to troubleshoot and fix this type of error.
Environment
- Jira Software Server/Data Center on 9.2.0 or any higher version
- Jira Service Management Server / Data Center on 5.2.0 or any higher version
Diagnosis
Go to the Outgoing Mail Server configuration page where the error is thrown (in ⚙ > System > Outgoing Mail Server), and check the username field:
- This field needs to be the email address of the user that logged into the Microsoft (or Google) Portal during the authorization process.
- If this field contains a value that is not an email address (for example "julien" instead of "julien@test.com"), or an incorrect email address, or an empty value, the connection test will fail and the authentication error will be thrown in the UI
- For example:
- The error below will be thrown in case the Mail Server is a Microsoft Server:
- The error below will be thrown in case the Mail Server is a GMAIL Server:
- The error below will be thrown in case the Mail Server is a Microsoft Server:
Cause
The username field of the Outgoing Mail Server configuration is incorrectly filled in. This field needs to be the email address of the user that logged into the Microsoft (or Google) Portal during the authorization process.
Note that, in theory, the username field should not be a mandatory field, since it is optional as shown in the UI. However, if this field is not filled in, the UI forces the Jira Admin to actually insert a value there in order to test the mail server connection.
This incorrect behavior is a bug tracked in the public ticket JRASERVER-74326 - The username field is treated as a mandatory field in the outgoing mail server configuration when using Oauth 2.0.
Solution
Set the username to the email address of the user that logged into the Microsoft Portal (or the Google Portal) during the authorization process: