The first step is to create a new connector in the Azure portal, which will allow you to connect your on-premises email server to Office 365.
You'll need to provide the fully qualified domain name (FQDN) of your email server and the authentication details, such as username and password.
Make sure to select the correct authentication method, either username and password or modern authentication.
The connector will then be created and you can start sending emails from your on-premises server to Office 365.
To ensure that emails are delivered successfully, you'll need to configure the DNS settings for your domain. This includes creating a TXT record for SPF and a MX record for mail routing.
The SPF record will help prevent spam and phishing emails from being sent from your domain, while the MX record will direct incoming emails to the correct mail server.
By following these steps, you'll be able to set up and configure SMTP in Azure Office 365 with ease.
Office 365 Setup
To set up Office 365 for SMTP authentication, you first need to check if it's already enabled in your tenant. There are two main ways to do this.
Before making any configuration changes, it's essential to verify whether SMTP authentication is already enabled for your Office 365 organization or for particular user accounts as required. You can enable it through the following methods if it's not.
For applications on your network, you can configure "direct send" to Office 365's MX record as the target SMTP server, which doesn't require Office 365 credentials. This setup is a good option for applications that need to send mail without authenticating.
Office 365 Overview
Office 365 is a powerful tool for businesses and individuals alike. It offers a wide range of features and capabilities that can help you stay organized and productive.
You can enable SMTP authentication in Office 365 if it's not already set up, which is necessary for some testing and troubleshooting. This can be done through the Office 365 admin center.
Having a good understanding of Office 365's capabilities and features is essential for getting the most out of it. You can use it to manage your email, calendar, and contacts, as well as collaborate with others on documents and projects.
If you're testing your email setup, you may need to enable SMTP authentication for your Office 365 organization or for specific user accounts. This can be done through the Office 365 admin center.
Office 365 Enabled Check
Before setting up Office 365, it's essential to check if SMTP authentication is already enabled in your Office 365 tenant. There are two main ways to do this.
You can check the Office 365 admin center or use the Microsoft Remote Connectivity Analyzer to verify the status of SMTP authentication. The admin center provides a clear view of your tenant's configuration, while the Remote Connectivity Analyzer offers a more comprehensive test of SMTP connectivity.
To verify SMTP authentication, you can check the Office 365 admin center or use the Remote Connectivity Analyzer. The admin center provides a clear view of your tenant's configuration, while the Remote Connectivity Analyzer offers a more comprehensive test of SMTP connectivity.
If you're unsure about the status of SMTP authentication, you can use the Microsoft Remote Connectivity Analyzer to test it. This tool will validate DNS records, perform an SMTP EHLO/HELO test, attempt an SMTPAUTH login, and confirm TLS availability.
Here are some common SMTP error codes to watch out for:
- 535 – Indicates a general authentication failure
- 535 5.7.3 – Authentication unsuccessful
- 535 5.7.139 – Authentication unsuccessful, account not configured for SMTP
- 530 – Access denied due to invalid credentials
- 534 – Authentication failed
- 454 – TLS not available due to temporary reason
Capturing the exact SMTP error codes and messages will help narrow down the problem and guide your troubleshooting efforts.
Troubleshooting SMTP Issues
If you're having issues sending email after enabling Office 365 SMTP authentication, here are some troubleshooting tips.
First, check that your SMTP server is set up correctly. Make sure to enable Office 365 SMTP authentication in the settings.
Ensure that your username and password are correct, as incorrect credentials can cause issues. If you're still having trouble, try resetting your password.
If you're using a third-party email client, check that it's configured to use Office 365 SMTP authentication. Sometimes, the client may need to be updated or reconfigured.
Troubleshooting Issues with SMTP Authentication can be a challenge, but a fresh start often helps. Try deleting and re-adding your email account.
Configuring Azure SMTP
Configuring Azure SMTP involves understanding Azure's default outbound SMTP settings. Port 587 is open by default, allowing outbound SMTP connectivity.
Azure's default outbound SMTP settings block port 25, but you can open it to any destination if needed. However, this might not be the most secure option.
To securely configure Azure SMTP, you can use Network Watcher to diagnose network flows and outbound VM connectivity problems. This can help you identify the specific issue and find a more secure solution.
Verifying Azure AD and Exchange Online Configurations
Verifying Azure AD and Exchange Online Configurations is crucial to ensure successful SMTP authentication. You'll want to confirm that the account has an Office 365 or Exchange Online license assigned, as accounts without proper licenses will fail to authenticate.
First, check that multi-factor authentication is not enabled on the account if using basic authentication, as MFA will break basic auth. This is a common gotcha that can be easy to overlook.
Application Impersonation delegation rights should be properly configured if authenticating via a service principal. This ensures that the service principal has the necessary permissions to access the mailbox.
In Exchange Online, validate that the mailbox or shared mailbox has SMTP AUTH enabled and proper permissions configured. This is a critical step to ensure that the mailbox can receive and send emails via SMTP.
You should also ensure that there are no inbox rules, transport rules, or other policies blocking SMTP AUTH. These rules can be set up by administrators to control email flow, but they can also interfere with SMTP authentication.
Finally, check for Exchange Online PowerShell session expiration, which can cause auth failures. This is an easy mistake to make, especially if you're working with multiple sessions.
Here are some key configuration checks to keep in mind:
- Azure AD: Confirm Office 365 or Exchange Online license, disable MFA if using basic auth, and verify Application Impersonation delegation rights.
- Exchange Online: Validate SMTP AUTH, check for inbox rules and transport rules, and ensure PowerShell sessions are not expiring.
One Answer
Port 587 is open from Azure outbound, but port 25 is blocked by default, depending on the subscription type.
This can cause issues with sending emails, as seen in the example where the issue was that the outbound connectivity was blocked by the Azure firewall.
The Azure firewall blocks traffic to ports 587 and 25, which can be frustrating, especially when trying to configure Azure SMTP.
To allow traffic to the Office 365 relay service, you can do an open on ports 25 and 587 to any destination, but this might not be the most secure option.
A better approach is to use Network Watcher to diagnose network flows and outbound VM connectivity problems, as suggested in the comment by Greg W.
This tool can help you identify the specific issue and find a more secure solution.
Here's a quick summary of the ports involved:
- Port 587: Open from Azure outbound
- Port 25: Blocked by default, depending on the subscription type
Blocking Email Spam
Blocking email spam is a crucial step in maintaining a secure and efficient email system. You can block IP addresses that are sending spam by adding them to the connection filter IP block list.
To do this, you'll need to obtain the headers for the message you want to block, which can be done in your mail client, such as Outlook, or Outlook on the web. The IP address you're looking for is usually found following the CIP tag in the X-Forefront-Antispam-Report header.
Once you have the IP address, you can create an IP Block list and add it to the list. This process is the same whether you're creating a new policy or editing an existing one.
You can also filter email messages based on language or region. For example, you can configure the service to quarantine messages written in Arabic or sent from Australia. To do this, you'll need to select the Filter email messages written in specific languages or sent from specific countries or regions checkbox.
Here's a breakdown of the international spam filtering options:
By default, if no international spam options are selected, the service performs normal spam filtering on messages sent in all languages and from all regions.
Diagnostics Tool
Microsoft provides a powerful tool for troubleshooting SMTP issues, the SMTP Authentication Diagnostics Tool. This tool can automatically detect Exchange Online misconfigurations, check for disabled accounts or passwords, validate proper licenses are assigned, and test end-to-end email delivery.
With the diagnostics tool, you can save time troubleshooting and identify potential issues that might be causing your SMTP connection to be blocked in Azure. It's a game-changer for anyone trying to resolve SMTP issues.
The diagnostics tool can:
- Automatically detect Exchange Online misconfigurations
- Check for disabled accounts or passwords
- Validate proper licenses are assigned
- Test end-to-end email delivery
By using the diagnostics tool, you can get to the root of the issue and resolve it quickly, restoring your email sending capabilities in no time.
Limits and Policies
To limit potential abuse of authenticated SMTP, you can create an Exchange Online mail flow rule to enforce organization-wide send limits. This will throttle Office 365 SMTP usage at an organization level as an added protection.
To create such a rule, navigate to Mail flow > Rules in the Exchange Admin Center, click New [+] > Create a new rule, and give it a name like "Enforce Daily Send Limits." Set conditions to match all messages from any sender and for actions, select Throttle message delivery.
You can also configure granular send limits on inbound mail connectors. In addition, you can create custom policies to specify the users, groups, and/or domains for whom to apply send limits.
Custom policies can be created by selecting the Apply to menu item and creating a condition-based rule to specify the users, groups, and/or domains for whom to apply the policy. To add senders who aren't on the list, type their email addresses and click Check names.
Daily Send Limits
Daily Send Limits are a crucial aspect of maintaining a secure and organized email system. To enforce organization-wide send limits, you can create an Exchange Online mail flow rule.
This rule will throttle Office 365 SMTP usage at an organization level, providing an added layer of protection. You can configure the rule in the Exchange Admin Center (EAC) by navigating to Mail flow > Rules.
To create the rule, click New [+] > Create a new rule and give it a name like “Enforce Daily Send Limits”. Set conditions to match all messages from any sender.
For actions, select Throttle message delivery. Save and apply the rule to implement the daily send limits.
Custom Policies Only
Custom policies only allow you to specify the users, groups, and/or domains for whom to apply this policy. You can create multiple conditions, as long as they are unique.
To add senders, select one or more users from your company from the user picker list and click "add". If a sender isn't on the list, you can type their email address and click "Check names". You can also use wildcards for multiple email addresses, such as *@domainname.
You can create exceptions within the rule by clicking "add exception" and creating your exception conditions. This allows you to filter messages from all domains except for a certain domain.
To enable or disable your custom policies, select or clear the checkboxes in the ENABLED column. All policies are enabled by default, and the default policy cannot be disabled.
You can delete a custom policy by selecting it, clicking the Delete icon, and confirming that you want to delete it. The default policy cannot be deleted.
Custom policies always take precedence over the default policy. They run in the reverse order that you created them, but you can change the priority by clicking the Up Arrow and Down Arrow. The policy with a PRIORITY of 0 will run first.
Testing and Verification
Testing and Verification is a crucial step in ensuring your Office 365 SMTP connections are working as expected. You can use Telnet or an SMTP client library to directly test SMTP authentication.
To validate how Office 365 is handling SMTP connections, you need to connect to smtp.office365.com on port 587 using Telnet or OpenSSL. Try sending an email from an Office 365 accepted domain without any authentication to see if SMTP authentication is enabled in your tenant.
If the command fails with an error like "Authentication Required" or "Must issue a STARTTLS command first", SMTP authentication is likely enabled. Try reconnecting and sending the test email again with a valid Office 365 username and password configured in AUTH LOGIN per RFC 4954.
If the email sends successfully, SMTP authentication is working properly. But if it fails with an authentication error, there is still an issue with SMTP authentication for your tenant or user account.
Some additional tips for testing SMTP authentication include trying different ports (25, 587, and 465) to test different configurations, and validating behavior for both internal and external IP addresses if you will be sending from multiple networks.
Here are some specific ports to test:
You should also test with both user accounts and shared mailboxes to confirm consistent behavior, and capture SMTP banner messages and error codes to troubleshoot failures. Reviewing Office 365 SMTP logs after testing can also help verify authentication attempts.
Frequently Asked Questions
Does Azure block SMTP?
Yes, Azure blocks outbound SMTP connections on TCP port 25 for deployed VMs. This block is in place to enhance security and comply with industry standards.
Sources
- https://learn.microsoft.com/en-us/defender-office-365/external-senders-use-the-delist-portal-to-unblock-yourself
- https://wpmailsmtp.com/docs/how-to-set-up-the-outlook-mailer-in-wp-mail-smtp/
- https://blog.mystrika.com/smtp-authentication-office365/
- https://www.clouddirect.net/knowledge-base/KB0011008/blocking-email-spam-with-the-office-365-spam-filter-for-administrators
- https://serverfault.com/questions/1106297/smtp-azure-firewall-rule
Featured Images: pexels.com