You know that Laravel provides several mail drivers like SMTP
, mail, sendmail
, mailgun
, mandrill, etc. Did you know that we can also send mail using office365 smtp server in laravel 6, laravel 7, laravel 8 and laravel 9 versions? In this example, I will show you how to send emails in Laravel using the office365 smtp server.
Before using this office365 service for sending mail in laravel, we have to configure our .env file according to office365 server requirements. So update the env file like below to use office365 service for sending mail in Laravel.
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=email
MAIL_PASSWORD=app_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=email
MAIL_FROM_NAME="your app name"
Hope it can help you.
#laravel #laravel-9x #laravel-mail