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]
Hello
@Yosua Ferdian
!
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 |
Hi
@Yosua Ferdian
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.