简体   繁体   中英

Error when I send email using Office365 in Laravel

In Laravel 7, I want to send email from my application using Office365, tried email password and app password none worked.

MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"

You have to use your email instead of password on MAIL_FROM_ADDRESS like this

MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"

or you can use smtp-mail.outlook.com as MAIL_HOST

MAIL_MAILER=smtp
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"

you need to put the password in double-quotes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM