Sending SMTP email via our website error 535 5.7.139 Authentication unsuccessful

Aris Lacdao 1 Reputation point
2022-05-13T08:13:59.813+00:00

We're sending email from our website via SMTP using ******@ourcompany.com.

We are using these settings to send email:

MAIL_MAILER=smtp  
MAIL_HOST=smtp.office365.com  
MAIL_PORT=587  
MAIL_USERNAME=******@ourcompany.com  
MAIL_PASSWORD=xxxxxxx  
MAIL_ENCRYPTION=tls  
MAIL_FROM_ADDRESS=******@ourcompany.com  
MAIL_FROM_NAME="NOREPLY"  

MFA is enabled, SMTP AUTH is enabled and we created an App password for ******@ourcompany.com.

Upon sending an email we are encountering an error: 535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully.

I already research how to fix this and I saw this question: https://learn.microsoft.com/en-us/answers/questions/512954/535-57139-authentication-unsuccessful.html

I can't set Enable security defaults to No because this account is company wide I want to keep this value to Yes. I just want ******@ourcompany.com only to send emails via SMTP.

Then I saw that I can allow Legacy Authentication only on ******@ourcompany.com via Conditional access maybe this will solve my problem. But when I go to Conditional Access I'm seeing this page:

201732-screenshot-from-2022-05-13-16-03-52.png

Our account is not on Azure AD Premium. So we cannot send SMTP email unless our account is on Premium?

Exchange | Exchange Server | Management
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 119.7K Reputation points MVP Volunteer Moderator
    2022-05-13T10:33:02.12+00:00

    You cannot use App passwords for SMTP send, you'll have to disable MFA for the account you want to send with.

    1 person found this answer helpful.

  2. Kael Yao 37,746 Reputation points Moderator
    2022-05-16T06:07:31.303+00:00

    Hi @Aris Lacdao

    Please refer to this link: Basic Authentication Deprecation in Exchange Online – May 2022 Update

    Here are some screenshots from the discussion:
    202177-19.png

    202147-20.png

    If you would like to use basic auth, it is required to disabled Security Defaults.
    Otherwise you may need to use modern auth instead.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

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