SMTP ERROR: OAuth TOKEN command failed: 535 5.7.3 Authentication unsuccessful.
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:
- Navigated to Azure Active Directory > App registrations and selected my application.
- Opened the API permissions section and clicked + Add a permission.
- Chose the Microsoft Graph tile.
- Selected Delegated permissions for sending emails on behalf of a signed-in user.
- In the search box, typed Mail.Send and selected the permission from the results.
- Clicked Add permissions.
- 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?