Allow Office365 e-mail alerts using username and password authentication
If you want to send outgoing email through Office 365 without using OAuth 2.0 authentication,
Microsoft still provides the option to authenticate using a traditional username and password using TCP port 587 and STARTTLS for transport encryption
However, this legacy authentication method must first be enabled in Exchange Online.
If the required settings are not enabled, SMTP authentication attempts will fail, even when the username and password are correct. In that case, you may receive the following error message:
535 5.7.3 Authentication unsuccessful
or
535: 5.7.139 Authentication unsuccessful, user is locked by your organization's security defaults policy
To allow legacy SMTP authentication, you must ensure that the appropriate settings are enabled in Exchange Online:
- SmtpClientAuthenticationDisabled must be set to False so that SMTP AUTH is allowed.
- AllowLegacyTLSClients may need to be set to True when using legacy TLS clients or applications.
This article explains how to configure the required Exchange Online settings.
Step 1: Install the Exchange Online PowerShell module
In Powershell, execute the following command:
Install-Module ExchangeOnlineManagement -Scope AllUsers
NOTE: Answer Y (Yes) or A (All) to any prompt.
Then, verify the installation:
Get-Module ExchangeOnlineManagement -ListAvailable
You should see the installed version listed.
Step 2: Connect to Exchange Online
Connect-ExchangeOnline -UserPrincipalName administrator@yourdomain.dom
A Microsoft 365 sign-in window should appear. After signing in with an Exchange Admin or Global Admin account, you're connected to Exchange Online.
Step 3: Set SMTP AUTH settings
The following command allows Microsoft 365 mailboxes to authenticate with a username and password when sending email through the SMTP protocol:
Set-TransportConfig -SmtpClientAuthenticationDisabled $false
The folowing command allows legacy clients that do not support modern encryption standards such as OAuth2 to connect to the legacy SMTP endpoint:
Set-TransportConfig -AllowLegacyTLSClients $true
