Exchange 2016 relays mail for internal devices only through a dedicated Receive connector. Microsoft says to create a new connector for Frontend Transport. Permissions come from one of two methods and never from both. Narrow remote IP ranges protect the server from open relay. Telnet testing confirms the setup.
Printers, web servers and monitoring tools need a way to send mail through Exchange without a mailbox login. Anonymous relay solves that for named hosts. Wrong settings make the server an open relay that spammers use.
Facts follow the Microsoft Learn page Allow anonymous relay on Exchange servers for Exchange 2016, 2019 and Subscription Edition. Page Send email from devices and applications adds the Microsoft 365 options.
Why Not Use the Default Connectors?
Microsoft calls open relay a very bad thing for servers on the internet. Spammers seek out open relay servers.
Microsoft says never to add anonymous relay to the default connectors. Create a dedicated connector instead. Default Frontend listens on TCP port 25 from any source. Default connector of the Transport service listens on port 2525.
How to Create the Relay Receive Connector?
- Open the Exchange admin center and select Mail flow and Receive connectors. Select Add.
- Enter a name like Anonymous Relay. Select Frontend Transport as the role and Custom as the type.
- Accept the network binding on port 25 or bind one internal IP address.
- Remove the default remote range 0.0.0.0-255.255.255.255. Add the IP addresses of the allowed hosts.
- Select Finish.
Microsoft advises erring on the side of being too specific instead of too general for the remote range.
New-ReceiveConnector -Name "Anonymous Relay" -TransportRole FrontendTransport -Custom -Bindings 0.0.0.0:25 -RemoteIpRanges 192.168.5.10,192.168.5.11
Which Permission Method Fits?
Relay needs five permissions on the connector. Microsoft names accept headers routing, accept any recipient, accept any sender, accept authoritative domain sender and SMTP submit. Choose one method.
| Method | Strength | Weakness |
|---|---|---|
| Anonymous users | Grants only the minimum permissions. | Needs the Exchange Management Shell. Messages go through antispam and size checks. Sender names are not resolved from the address list. |
| Externally secured | Easier to set up and possible in the admin center. Sender names resolve from the address list. | Treats the hosts as fully trusted. Messages bypass antispam and size checks. |
::Anonymous users method
Set-ReceiveConnector "Anonymous Relay" -PermissionGroups AnonymousUsers
Get-ReceiveConnector "Anonymous Relay" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "Ms-Exch-SMTP-Accept-Any-Recipient"
::Externally secured method
Set-ReceiveConnector "Anonymous Relay" -AuthMechanism ExternalAuthoritative -PermissionGroups ExchangeServers
How to Test the Relay With Telnet?
- Open a command prompt on an allowed host and type telnet.
- Type set localecho and then OPEN followed by the connector IP address and port 25.
- Type EHLO. Then type MAIL FROM with an address from an accepted domain.
- Type RCPT TO with an external address. Reply 250 2.1.5 Recipient OK means relay is allowed. Reply 550 5.7.1 Unable to relay means it is denied.
- Type DATA and enter a subject and a short body. Finish with a line that contains only a period. Expect 250 2.6.0 Queued mail for delivery.
- Type QUIT.
Reply 550 5.7.1 points to a wrong connector IP address, a test host outside the remote range or missing permissions. When relay fails only at times, check the throttling limits on the Receive connector.
What About Microsoft 365?
Microsoft recommends an on-premises server for SMTP relay when you have one. For Microsoft 365 it lists SMTP relay on port 25 with a certificate or a static public IP and notes that relay cannot serve third-party cloud services like Azure. See how to fix Exchange SMTP error 550 5.7.1 for related errors.
What does Microsoft Not Say?
Microsoft gives no values for message rate limits. It names none for Exchange 2013 or older versions either. Older posts describe the default Receive connector for relay, which Microsoft advises against.
Frequently Asked Questions
How do You Set up SMTP Relay in Exchange 2016?
Create a dedicated Receive connector for Frontend Transport, limit it to the IP addresses of the sending hosts and grant relay permissions with one method.
What is Open Relay?
Open relay means a server forwards mail from anyone to anywhere. Spammers seek out such servers and Microsoft says never to configure one.
Can You Use the Default Receive Connector?
No. Microsoft advises a dedicated connector instead of the defaults.
Which Port does Anonymous Relay Use?
Port 25 in the Microsoft example.
Why does Relay Fail Sometimes?
Message rate and throttling limits on the Receive connector. Microsoft points to those limits for relay that fails at times.
Key Takeaways
- Create a dedicated Receive connector for Frontend Transport.
- Limit the remote IP ranges to the sending hosts.
- Choose Anonymous users or Externally secured permissions and never both.
- Test with Telnet and look for the 250 2.1.5 reply.
- Open relay gives spammers a path to send mail through the server.
Sources and References
Facts follow Microsoft Learn.
- Allow anonymous relay on Exchange servers (Microsoft Learn) learn.microsoft.com
- Send email from devices and applications (Microsoft Learn) learn.microsoft.com