question

YosuaFerdian-1459 avatar image
0 Votes"
YosuaFerdian-1459 asked joyceshen-MSFT commented

Failed to authenticate on smtp server outlook in laravel.

There's any way to authenticate in to outlook account with OTP code protection for SMTP use in laravel?
i am trying with setting:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=(username)
MAIL_PASSWORD=(password)
MAIL_ENCRYPTION=tls
MAIL_FROM=(email/username)

and i got error= Failed to authenticate on SMTP server with username "(email)" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [SG2PR03CA0140.apcprd03.prod.outlook.com]
". Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful [SG2PR03CA0140.apcprd03.prod.outlook.com]
".

office-outlook-itprooffice-exchange-online-itpro
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @YosuaFerdian-1459

Is there any progress about your issue? Can you send the message successfully now?

0 Votes 0 ·
Taz-3478 avatar image
0 Votes"
Taz-3478 answered Taz-3478 edited

Hello @YosuaFerdian-1459 !


Hope you are having a great day!

Can you try changing the "MAIL_DRIVER=smtp" to “MAIL_DRIVER=SendMail” and use the Office 365 TLS settings.



Let me know if the above solution solves your issue. I will be glad to help you!

Thank you,
Tasadduq



| Please don't forget to Upvote and Accept as answer if the reply is helpful |

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

joyceshen-MSFT avatar image
0 Votes"
joyceshen-MSFT answered

Hi @YosuaFerdian-1459

According to my research, one of the possible cause for the issue is: If your mail password contains a "#" then you should quote the environment string since everything after # will be taken as comment

For example:

 MAIL_PASSWORD = r39304#d^fd
 MAIL_PASSWORD = "r39304#d^fd"

If an Answer is helpful, please click "Accept Answer" and upvote it.

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.