AuthenticationFailedException: 526 Authentication failure[0] solution

0. Summarize the cause of the bug in one sentence

The project changed the mailbox server, and the account format supported by the original server is not supported on the new server; that is, the account number sent to the new server is wrong.

1 Overview

(1)bug:

The java program notifies the Alibaba Cloud mailbox server of failure to send emails.
Exception error message: AuthenticationFailedException: 526 Authentication failure[0].

(2) Background:

After abandoning the original mailbox server and replacing it with Alibaba Cloud mailbox server, all versions of the project sent no response to the email request sent to the server.

(3) Troubleshooting:

AuthenticationFailedException, the translation is authentication failure exception; the reasons for authentication failure are generally: server error, username error, username and password do not match.
Alibaba Cloud Official Troubleshooting Reference Link: How Alibaba Mailbox Sends Letters Through the SMTP Program
The parameters are configured in Foxmail, and the SMTP letter can be successfully sent. In this step, it is confirmed that the server is correct, the username is correct, and the username and password match.
So, what went wrong?
Read the original text on the official website:
insert image description here
After investigation, there is no error in the configuration and port of the SMTP server; then the problem lies in the code logic and parameters.
At that time, there were no doubts about the code logic and parameters: the code continued to use the part that was connected to the server before; the parameters that needed to be changed were all stored in the database, and these parameters had been verified on Foxmail.
Leave the problem to Alibaba Cloud, and the engineer checks the operation log and confirms that the account password received by the server is wrong.
Based on the error point, restart the disk: the server is fine, the account password of the database is fine, that is, there is a problem with the account password sent to the server after the java program processes it! The program got the correct account password, but sent the wrong one to the server.
Check in the code blocks that may be wrong: debug all the way from the src folder code to the source code of the hutool tool library, and find that the Alibaba Cloud mailbox server cannot recognize the email account; the same code logic, the valid account sent to the original server is "tairui", The Aliyun server needs "[email protected]".
Finally, the email account string was reassembled, and the problem was solved.

Guess you like

Origin blog.csdn.net/PanYiAn9/article/details/131709625