I have a website application that needs to send email via our Exchange servers. It sends email internally fine, but when sending to an external address I get the 550 5.7.1 unable to relay error. I followed this guide to create a connector to allow relay. Unfortunately, all office email was trying to use that connector and was not being routed correctly. It also appeared as though it opened it up for spammers to use. This is obviously unacceptable and a secure method is needed.
In your new scope did you only setup the IP of the web server as being able to send mail? If you limit the connector to only receive mail from your webserver that should take care of it.
Alternatively if you can setup your web app to use authenticated SMTP sessions you wouldn't need a new connector.
This problem occurs because by default the receive connector in Exchange Server 2007 does not have its default domain value set. This is unlike the behavior in Exchange 2000 or 2003 where it automatically appended the default domain to values that are submitted to MAIL FROM: or RCPT TO: in the message envelope by a sending server if no domain name is provided.
In Exchange Server 2007/ 2010, the default domain value on the receive connector is not set by default. If no domain name is specified in the MAIL FROM: or RCPT TO: commands, Exchange Server 2007 rejects the message with “501 5.1.7 Invalid Address” response.
To resolve this problem, perform the following steps to set the default domain value on the receive connector from Exchange Management Shell:
Click Start, click All Programs, click Microsoft Exchange Server 2007 and click Exchange Management Shell.
Run the following cmdlet to view the current setting of the default domain value on your receive connector:
Get-ReceiveConnector -identity <YourReceiveConnectorName> |fl
In the output, notice that the value of DefaultDomain is blank by default.
Run the following cmdlet to set the default domain value:
Set-ReceiveConnector -identity “<YourReceiveConnectorName>” -DefaultDomain “<YourSMTPDomainName>”
Set-ReceiveConnector -identity “Default EX2007MAIL” -DefaultDomain “contoso.com”
Get-ReceiveConnector -identity <YourReceiveConnectorName> |flcmdlet again and verify that the DefaultDomain has been set in the output.
Please follow this guide: http://technet.microsoft.com/en-us/library/bb232021.aspx
Make sure you restrict the connector to your internal ip addresses which are allowed to relay mails. (-RemoteIpRanges)
New-ReceiveConnector -Name "Anonymous Relay" -Usage Custom -PermissionGroups AnonymousUsers -Bindings 10.2.3.4:25 -RemoteIpRanges 192.168.5.77
Get-ReceiveConnector "Anonymous Relay" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "Ms-Exch-SMTP-Accept-Any-Recipient"