Back
Featured image of post Outlook Smtp Oauth2 Error

Outlook Smtp Oauth2 Error

In this blog, I used Outlook's SMTP service when accessing email alerts in the comment system, but I found an error when using it.

Introduction

When the comment system of this blog was connected to the email reminder, the SMTP service of Outlook was used, but when using it, it was found that there was no email reminder.

View the log

So I went to Vercel to check the log, as shown below:

Walline project deployed by Vercel - Sending email reminder error
Walline project deployed by Vercel - Sending email reminder error

The error stack is as follows:

1
2
3
4
5
Mail send fail: Error: Invalid login: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [CH0PR13CA0024.namprd13.prod.outlook.com 2024-11-15T12:41:27.364Z 08DD02E8CBA00082]
at SMTPConnection._formatError (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:807:19)
at SMTPConnection._actionAUTHComplete (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:1586:34) at SMTPConnection.<anonymous> (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:1540:18) at SMTPConnection._processResponse (/var/task /node_modules/nodemailer/lib/smtp-connection/index.js:991:20) at SMTPConnection._onData (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:772:14) at TLSSocket.SMTPConnection._onSocketData (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:195:44) at TLSSocket.emit (node:events:519:28) at TLSSocket.emit (node:domain:488:12) at addChunk (node:internal/streams/readable:559:12) at readableAddChunkPushBy teMode (node:internal/streams/readable:510:3) { code: 'EAUTH', response: '535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [CH0PR13CA0024.namprd13.prod.outlook.com 2024-11-15T12:41:27.364Z 08DD02E8CBA00082]', responseCode: 535,
command: 'AUTH LOGIN'
}

Source of this article

No one seems to have raised this question in waline’s discussions, maybe I’m the only one using Outlook…

Just look at the first line: Mail send fail: Error: Invalid login: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled., which means that Outlook’s SMTP service does not support basic authentication. I searched and found that Outlook stopped supporting basic authentication for individual users on September 16, 24, and recommended using OAuth2 authentication. See | Microsoft official website But I didn’t find support for OAuth2 in the waline document.

Write a plug-in yourself?

It seems unnecessary to write one for a comment system, after all, human energy is limited (~~ I won’t say I’m a novice~~)

Solution

So today’s protagonist: sendas.email

I will use the project deployed by the author here, and I won’t redeploy it again. If you want to deploy it yourself, you can fork the author’s project first, and then deploy it yourself. The deployment method is as shown below:

Deployment method
Deployment method

Start solving

Enter sendas.email, then scroll down to the bottom and click Sign in with Microsoft

Sign in with Microsoft | sendas.email
Sign in with Microsoft | sendas.email

When logging in, Microsoft will prompt you whether to allow third-party applications to access your account. Click Accept.

Authorize
Authorize

After authorization, the Microsoft account team will send an email reminder:

Email reminder
Email reminder

At this time, return to sendas.email, the website automatically redirects to the configuration page, the page is as shown below:

Show new username + password
Show new username + password

Modify environment variables

Next, return to the deployment of vercel and replace the previous password with the new password.

Correspondence
Correspondence

Please note that if you used SMTP_SERVICE before, you need to delete it now and add SMTP_HOST and SMTP_PORT.

SMTP_SERVICE is used
SMTP_SERVICE is used

Complete the environment variable configuration of vercel, as shown below:

Email configuration
Email configuration

Restart the project, and then you can send emails normally.

Restart the project
Restart the project

Appendix

Reference

This article was originally published on CaiHongTu Blog, following the CC BY-NC-SA 4.0 agreement, please keep the original source when copying.

Licensed under CC BY-NC-SA 4.0
Last updated on Feb 12, 2025 21:23 CST
Built with Hugo
Theme Stack designed by Jimmy
© Licensed Under CC BY-NC-SA 4.0