Tutorials | PHP & MySQL | Laravel Framework

David Carr

Send emails with Office 365 SMTP

Office 365 is great for handling emails but it can also be used as an SMTP relay for your website. I've tried dedicated SMTP services with mixed results some work better than others. What I like about using Office 365 is it's easy to set up and very reliable. The added benefit of Office 365 is your sent emails saved in your sent folder! very handy.

Here are the SMTP credentials you need out of the box:

Host: smtp.office365.com
username: email_address
password: email_password
port: 587
encryption: tls

This will work without any setup, but if you have 2FA set up this will not work, instead, you need to create an app password. 

App passwords are passwords to be used for third party applications, this way you never expose your account password so it's a recommended approach even if you don't use 2FA but seriously use 2FA!

To set up app passwords login to your account click Manage security and privacy.

Next click on create and manage app passwords.

All your app passwords will be listed on this page, to add a new one click create.

Enter a name for the app password such as your website name.

Note down the generated app password it will not be displayed again. (the below is just an example)

Now with the pass password, you're ready to start sending emails with SMTP.

To use Office 365 with Laravel setup the .env file as follows

MAIL_FROM_NAME="your app name"


Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.