0

I’m trying to send an email with our Laravel app using Office365/Outlook. It has worked well with gmail but when I switched over to Office365, the following error appears:

Failed to authenticate on SMTP server with username
[email protected]” using 2 possible authenticators. Authenticator
LOGIN returned Expected response code 235 but got code “535”, with
message “535 5.7.3 Authentication unsuccessful
[HKAPR03CA0035.apcprd03.prod.outlook.com]
“. Authenticator XOAUTH2 returned Expected response code 235 but got code “535”, with message “535 5.7.3 Authentication unsuccessful
[HKAPR03CA0035.apcprd03.prod.outlook.com]
“.

This is what I have in my .env file:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=emailPassword
MAIL_ENCRYPTION=tls
MAIL_SMTPAuth=true
MAIL_FROM_NAME=CompanyName
[email protected]

*note: this is not the real username, password and from address.

I also tried changing the port to 25 but I get the same error

I’m using a dedicated support email from my company. And from what I confirmed with our IT, the support email does not have 2 factor authentication and the “Authenticated SMTP” setting is also enabled via the admin panel of Office365 so I don’t know what seems to be the problem.