Get-CASMailbox -Identity "user@domain.com" | Format-List SmtpClientAuthenticationDisabled
Join us
@idjuric660 ・ May 04,2024 ・ 11 min read ・ 1156 views ・ Originally posted on mailtrap.io
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.
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 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:
Some of the most common Office 365 SMTP use cases include:
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.
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)
PowerShell
Get-CASMailbox -Identity "user@domain.com" | Format-List SmtpClientAuthenticationDisabled
Set-CASMailbox -Identity "user@domain.com" -SmtpClientAuthenticationDisabled $false
Notes:
To send emails via Office 365 SMTP, enter the following settings into your app or email client:
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.
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:
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);
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:
Select ‘Outgoing Server (SMTP)’ at the bottom of the drop-down menu
Enter your Office 365 settings
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.
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.
To use Office POP3, insert these settings into your app configuration or email client:
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.
To use Office 365 IMAP, you’ll need the following settings:
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.
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:
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:
For more information on Office 365 and TLS, read the official Microsoft’s article.
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:
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:
Navigate to the ‘SMTP/API Settings’ tab and choose your preferred SMTP stream.
The article was originally posted on the Mailtrap blog. Check the article and explore more useful content!
Join other developers and claim your FAUN account now!
Technical Content Writer, Mailtrap
@idjuric660Influence
Total Hits
Posts
Only registered users can post comments. Please, login or signup.