I have setup a Laravel application on an Ubuntu droplet at DigitalOcean. Now I'm trying to send out e-mails using an office 365 mail account. However I get the following error:
Failed to authenticate on SMTP server with username "info@example.com" using the following
authenticators: "LOGIN", "XOAUTH2". Authenticator "LOGIN" returned "Expected response code
"235" but got code "535", with message "535 5.7.139 Authentication unsuccessful,
SmtpClientAuthentication is disabled for the Mailbox. Visit
https://aka.ms/smtp_auth_disabled for more information.
[AS4P192CA0012.EURP192.PROD.OUTLOOK.COM 2023-05-22T18:20:29.187Z 08DB5A 1254806496]".".
Authenticator "XOAUTH2" returned "Expected response code "235" but got code "535", with
message "535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for
the Mailbox. Visit https://aka.ms/smtp_auth_disabled for more information.
[AS4P192CA0012.EURP192.PROD.OUTLOOK.COM 2023-05-22T18:20:39.951Z 08DB5A1254806496]".".
I'm using the following configuration in the .env file:
MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME="info@example.com"
MAIL_PASSWORD=***PASSWORD***
MAIL_ENCRYPTION=STARTTLS
MAIL_FROM_ADDRESS="info@example.com"
MAIL_FROM_NAME="${APP_NAME}"
I read that I could enable/disable SMTP auth (https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission). I guess that is the setting as in the screenshot below. I tried with the checkbox both checked and unchecked, but it makes no difference.
So the question is: what am I missing to get smpt working on my website?
The error message gives the suggestion to visit this page: https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission. So I tried with Authenticated SMTP checked and unchecked and saw no change.
Finally I found out from here: https://mkerala.com/solution-535-5-7-3-authentication-unsuccessful-office-365-smtp-error/ that it takes a while for the setting to take effect. In my case about 20 minutes.