Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

Send emails with Office 365 SMTP

David Carr

Laravel Framework Tutorials PHP & MySQL

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:

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"


Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!


My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.