When creating a custom receive connector in Exchange it does not allow external relay of mails to the internet. So in order to achieve this, we have to manually assign permission to relay to external domains. First, we need to create a receive connector in exchange.
New-ReceiveConnector -Name “Application Relay” –Server EX01.contoso.com -Usage Custom -Bindings 0.0.0.0:25 -RemoteIPRanges 192.168.1.1 –TransportRole FrontendTransport -PermissionGroups AnonymousUsers
In the above command, the parameters PermissionGroups are set to AnonymousUsers so that the IP from which you need to relay the mail can anonymously send without any authentication. In the parameter RemoteIPRanges, we can mention the IPs from which you need to relay your mail. After creating the connector in order to relay emails to domains on the internet we need to execute the below also in the exchange management shell.
Get-ReceiveConnector "EX01\Application Relay" | Add-ADPermission -User 'NT AUTHORITY\Anonymous Logon' -ExtendedRights MS-Exch-SMTP-Accept-Any-Recipient
The above command adds the permission to relay to external domains on your connector that you created previously.
