SMTP ERROR: OAuth TOKEN command failed: 535 5.7.3 Authentication unsuccessful.

kathir 0 Reputation points
2025-10-14T04:36:57.7633333+00:00

Hi, My name is Kathir.

I’m using an Outlook account: kathir***@outlook.com Account type: Personal account.

This account is mainly used for SMTP with PHPMailer.

**Previously, I received an error stating that Basic Authentication is disabled. So, I tried to migrate from Basic Authentication to Modern Authentication (OAuth 2.0). ** I followed these steps in the Azure Portal → App registrations section:

  1. Navigated to Azure Active Directory > App registrations and selected my application.
  2. Opened the API permissions section and clicked + Add a permission.
  3. Chose the Microsoft Graph tile.
  4. Selected Delegated permissions for sending emails on behalf of a signed-in user.
  5. In the search box, typed Mail.Send and selected the permission from the results.
  6. Clicked Add permissions.
  7. After adding the permission, clicked Grant admin consent and confirmed.

After that, I triggered the authorization URL, received the authorization code, and successfully generated the access token using the code.

I used the following scope: "scope" => "https://graph.microsoft.com/SMTP.Send offline_access"

However, when I tried to send an email through PHPMailer using this token, I received an “Unauthorized” error.

Error:"2025-10-14 04:22:52 SMTP ERROR: OAuth TOKEN command failed: 535 5.7.3 Authentication unsuccessful [SG2PR02CA0041.apcprd02.prod.outlook.com 2025-10-14T04:22:56.154Z 08DE09C6D0C4E5B4] SMTP Error: Could not authenticate."

I would like to confirm — does this “Unauthorized” error indicate a token issue or a code issue?

If it’s a token issue, how can I track the token problem? How is the token generated, and what factors affect it?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.