Site icon Mailtrap

Office 365 SMTP: Setup and Configuration Explained

In this guide, I dive deep into the ins and outs of Office 365, showing you what it’s best used for and how to configure it, while also providing you with some actual examples.

What is an Office 365 SMTP server?

SMTP, or Simple Mail Transfer Protocol, is an internet standard protocol responsible for delivering messages to the email server and relaying emails between senders and recipients. 

Thus, Office 365 is an SMTP service from Microsoft.

However, in 2020, Office 365 was renamed to Microsoft 365.

Microsoft 365 is a subscription-based service, which includes Office 365 SMTP. So, when you refer to the Office 365 SMTP, you refer to the Microsoft 365 SMTP.

However, we’ll be using Office 365 to keep things simple.

Office  365 SMTP vs. Outlook SMTP

Office 365 SMTP is often confused with Outlook SMTP on the internet, but don’t mix up the two, because Office 365 is subscription-based, whereas Outlook is free.

Here are some differences between the two:

Feature/AspectMicrosoft 365 SMTPOutlook SMTP
Service scopePart of the broader Microsoft 365 suite, which includes a range of paid productivity tools.Specifically refers to the SMTP settings provided by Outlook.
PricingSubscription-basedFree-to-use
Level of complexityCan be challenging for new users.Easy to set up and configure.
SMTP serversmtp.office365.comsmtp-mail.outlook.com
Related servicesWord, Excel, PowerPoint, One Drive, Exchange Online.Primarily email and calendar functionalities.

Why should you use Office 365 as a SMTP server?

Some of the most common Office 365 SMTP use cases include:

How to configure Office 365 SMTP server settings?

According to Microsoft’s official documentation, there are three options for configuring Office 365 SMTP server settings. Namely:

As you can see, especially if you’re a developer looking to add email-sending functionality to your application, SMTP AUTH client submission more or less takes the cake. 🎂

Now, let me show you how to configure it.

Step 1. Verify and enable SMTP AUTH 

First things first, we need to enable SMTP AUTH on your mailbox to send emails through Office 365 SMTP.

To check if SMTP AUTH is enabled, you can use:

Exchange Admin Center (EAC)

  1. Log in to the EAC with your admin account.
  2. Navigate to “Recipients” → “Mailboxes”
  3. Find and select your mailbox.
  4. Check the status of your SMTP AUTH

PowerShell

  1. Connect to Exchange Online PowerShell using your admin credentials.
    • You can also use ‘Connect-ExchangeOnline’ cmdlet
  2. Run the following command to check the SMTP AUTH of your mailbox:
Get-CASMailbox -Identity "user@domain.com" | Format-List SmtpClientAuthenticationDisabled
  1. If ‘SmtpClientAuthenticationDisabled’ is ‘False’, SMTP AUTH is enabled
  2. If ‘SmtpClientAuthenticationDisabled’ is ‘True’, SMTP AUTH is disabled
  3. Run the following command to enable SMTP AUTH for your mailbox:
Set-CASMailbox -Identity "user@domain.com" -SmtpClientAuthenticationDisabled $false

Notes:

Step 2. Insert the necessary Office 365 SMTP settings

To send emails via Office 365 SMTP, enter the following settings into your app or email client:

Configuration examples

Now that you’re familiar with Office 365 SMTP and know how to configure it, let’s see some actionable examples in WordPress, PHP, and Thunderbird.

WordPress Office 365 SMTP settings

If you’re a WordPress user, you can configure the Office 365 SMTP with plugins like WP Mail SMTP or Post SMTP for instance.

All you have to do is:

PHP

When it comes to PHP, you have several email-sending libraries to choose from. In this example, I’ll use Symfony because of its practicality.

Here’s a code snippet you can modify with your Office 365 credentials to send emails:

<?php

use Symfony\Component\Mailer\Mailer; 
use Symfony\Component\Mailer\Transport\Smtp\SmtpTransport; 
use Symfony\Component\Mime\Email;

require_once './vendor/autoload.php';


$transport = (new Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport
('smtp.server.com', 587))
                ->setUsername('username')
                ->setPassword('password');

$mailer = new Mailer($transport); 

$email = (new Email())
            ->from('hello@registered.com')
            ->to('you@example.com')
            ->subject('Time for Symfony Mailer!')
            ->text('Sending emails is fun again!')
            ->html('<p>See Twig integration for better HTML integration!</p>');

$mailer->send($email);

Thunderbird

As I’ve previously mentioned, besides custom applications, you can also set up email clients like Thunderbird to send emails through Office 365 SMTP.

Here’s how you can do it:

Keep in mind that I’ve used Thunderbird version 115.0 in this example, so there might be differences in your access to ‘Account Settings’ if you’re using an older version of the client.

How to configure Office 365 POP3 settings?

Once you’ve configured your Office 365 SMTP, you’ll need an ”email retrieval” or “pull protocol” for fetching messages from the server. One of such protocols is Post Office Protocol 3, or POP3 for friends.

POP3 lets you download messages from your Office 365 account to your local device. It can be useful if you have a limited connection and want to view your messages offline or if you want to create a backup of emails by storing them locally.

Office 365 POP3 settings

To use Office POP3, insert these settings into your app configuration or email client:

How to configure Office 365 IMAP settings?

Another pull protocol you can use to retrieve your emails is IMAP or Internet Message Access Protocol.

IMAP is considered by many a more convenient protocol than POP3 as it synchronizes your emails across your devices. It stores them on the email server, where you can manage, open, view, and delete your messages. In essence, IMAP works similarly to cloud email.

Office 365 IMAP settings

To use Office 365 IMAP, you’ll need the following settings:

POP3 vs IMAP – which one is better?

Simply put, POP3 and IMAP serve different purposes and fit different personal needs, so we can’t really say one is better than the other.

However, most users nowadays could benefit more from IMAP as we use different devices to fetch our emails. And as mobile networks have become more affordable and Wi-Fi is everywhere, the synchronization IMAP offers can really go a long way.

Moreover, IMAP is the default protocol for the majority of modern email clients.

But, whether you want to store your emails on your local devices for security reasons or for convenience’s sake, POP3 is the way to go for you.

Troubleshooting Microsoft Office 365 SMTP server configuration

I’ve scoured the community forums for the most common Microsoft Office 365 errors so you don’t have to, and here are some of the most common ones:

This error message means that you either don’t meet SMTP AUTH requirements or your network firewall or Internet Service Provider (IDP) are blocking ports 587 or 25.

In case you meet the requirements, here’s how you can check if you’re potentially getting blocked:

  1. Open Command Prompt (CMD) as an administrator
  2. Type ‘telnet’ to run telnet
  3. Run the following command:
    • open smtp.office365.com 587(25)

If you’re able to successfully connect, you will receive a response line similar to:

In case you can’t connect, try disabling your firewall or contacting your ISP.

Although a common error, this error is likely caused either by your antivirus software or firewall blocking your SMTP connection or a typo in your Office 365 settings. If neither of these solutions works, then the issue is probably on Microsoft’s end, in which case you’ll need to contact their support.

If you’re seeing this error, check whether your application or email client is trying to send emails from a different address than the one you’ve entered in your SMTP configuration. The two need to be the same for the sending to work.

But, you can also give the ‘Send As’ permission to another address if you plan to use two different addresses for email sending.

Recently, Microsoft has started rejecting connections to smtp.office365.com that use TLS1.0/1.1 for SMTP AUTH. So, make sure your device supports TLS version 1.2 or above.

But, if you need to use older versions of TLS for legacy clients and devices, you can:

  1. Go to Settings in your Exchange admin center
  2. Navigate to Mail Flow (under Security)
  3. Check “Turn on use of legacy TLS clients)
  4. Click “Save”

For more information on Office 365 and TLS, read the official Microsoft’s article.

Office 365 SMTP limitations or when not to use Microsoft Office as an SMTP server

While Office 365 does offer a reliable SMTP server, it has some considerable limitations that you should go over before deciding on it as your go-to option.

Namely, they include:

Consider an alternative — using Mailtrap Email Sending

If you’re like me and Office 365 SMTP limitations are too much for you, don’t worry—I have just the right solution.

I use Mailtrap, an Email Delivery Platform for developer teams to test, send, and control their email infrastructure in one place. 

Personally, I needed to send bulk mail, so I used Mailtrap’s Bulk Stream to send large amounts of marketing and promotional emails in my high-volume campaigns to enhance my deliverability even further.

Additionally, I use Mailtrap’s detailed analytics to check my bounce rates, open rates, click-through rates and other useful stats. This allows me to keep track of my email infrastructure and optimize it accordingly.

Mailtrap Email Sending also provides me with deliverability alerts every Monday to let me know how my emails are doing in the form of in-depth stats and I also get hourly alerts when a critical metric goes below a predetermined threshold.

As enhancing my deliverability goes, I make sure to test my emails before sending them out, a part of the email-sending process that goes with it like salt goes with pepper. 🧂

Without testing my emails, I risk having them being marked as spam, or, worst case scenario: their HTML template getting poorly rendered by certain web browsers.

Mailtrap Email Testing, a part of the Mailtrap Email Delivery Platform lets me check my spam score, inspect and verify my HTML/CSS and make sure it’s pitch-perfect before it reaches my recipients’ inboxes.

Lastly, and perhaps most importantly, Mailtrap is super easy to use.

Check it out:

Wrapping up

Although limited in functionalities, Office 365 SMTP is a perfectly fine solution for you if you’re looking to add a robust email-sending solution to your application.

However, if you want to be fully equipped with some of the best tools of the email-sending and testing trade, Mailtrap is definitely the way to go.

Happy sending! 📨

Exit mobile version