How To Send Email In Laravel Using Office365?

You know that Laravel provides several mail drivers like SMTP, mail, sendmailmailgun, 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"

 

Read also: How to Setup Zoho SMTP Server in PHP Laravel?

 

Hope it can help you.

 

#laravel #laravel-9x #laravel-mail