Did you ever figure out an answer for this? My company is experiencing the same error message when trying to set up STMP messages. I thought it might have something to do with the two step authentication process.
SMTP OAuth 2.0 - Client was not authenticated to send anonymous mail during MAIL FROM
I am testing OAuth 2.0 integration for SMTP and POP3 in a desktop application. The app has a service component that sends and receives emails from a single account in the background.
I set up a @harsh.com .com online account to test with. I started a trial of Azure and Office 365 using this account.
I registered my application in Azure and gave it permissions for the Graph API (Mail.ReadWrite, Mail.Send) as well as the Exchange API (full_access_as_app). In my app, I'm able to request and receive valid tokens from the endpoints for both APIs.
When I pass either token to the mail component and try to send a test email, I get the following error:
530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
This error comes after what appears to be a successful login to the SMTP server:
<smtpAuthenticate>
<smtp_host>smtp.office365.com</smtp_host>
<smtp_port>587</smtp_port>
<smtp_user>[test]@outlook.com</smtp_user>
<auth-method>XOAUTH2</auth-method>
<smtpAuthMethod>XOAUTH2</smtpAuthMethod>
<smtpAuthenticate>
<login_method>NONE or already authenticated</login_method>
</smtpAuthenticate>
<ConnectionType>SSL/TLS</ConnectionType>
</smtpAuthenticate>
I'm using the smtp.office365.com server to send over port 587 and it is TLS encrypted. This works fine when I use Basic Auth instead of OAuth. But as soon as I use "XOAUTH2" for the authentication method and pass the auth token, the test send fails.
When I research the error online, I get a lot of hits suggesting using the MX endpoint for the smtp server. I'm unfamiliar with MX endpoints, and it seems like this involves registering a domain on Azure, which I don't think is necessary in this case. Or am I wrong about that?
Does anyone know what could be the cause of this error in my case, or how to troubleshoot this further?