New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Using Office 365 SMTP server

Luigi Foscari February 12, 2021 by Luigi Foscari

I'm having trouble connecting my Office 365 STMP server to Statamic's mailing system. I don't know much about these kind of things. At the moment my .env looks like this:

MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=hidden
MAIL_ENCRYPTION=tls                                                                                                                                           
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

The data comes from this page. I tried using STARTTLS, but it wasn't recognized. I also made sure to enable the Authenticated STMP option in Office's settings. The password is an app password created for the purpose.

But if I try to send the test email I get the following error:

Swift_TransportException

Failed to authenticate on SMTP server with username "l[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 [AM3PR05CA0104.eurprd05.prod.outlook.com] ".

Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful [AM3PR05CA0104.eurprd05.prod.outlook.com] "

I think the credentials are correct, I don't have another candidate for the username and in the past the username always happened to be equal to the email address. Can anyone help me?

Thanks

Answered by Lewis Tyler!
>>>>>>> Answered <<<<<<<
2 Replies
1 Follower