Saturday, September 29, 2012

SMTP Relay in Exchange 2007 OR Exchange 2010 (for testing )& Restricting Outbound Email

You may want to do some email testing in the staging environment for real customers minus sending them actually.
By Default exchange is not open realy.
If you already have exchange in your environment and it is  used in the production. then you need to create another dummy domain for the testing. e.g stage.local.
You can use a VM for installing both AD & Exchange on a single machine.
Open up the
exchange MMC
                Server Configuration
                                Hub Transport
 create a "new Receive connector"




Now Open the powershell
Get-ReceiveConnector "StageTest" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "ms-Exch-SMTP-Accept-Any-Recipient"

The above will allow the relay to the Anonymous group for that connector.

Now as we may not want that email will go outside the machine (to real customers). We need to create a "transport rule".
Create a user mailbox  e.g  "catchall" .  This will be catch all the emails that you will be sending to the real customer.

open exchange MMC
Organization Configuration==>Hub Transport ==> Transport Rules

Click on the new transport rule on the right side>
Give it a name e.g Mail Redirect


This should do the trick. To be extra sure you can remove the DNS and Gateway entry of the machine. (in that way this machine will  work inside the LAN only)

A Receive connector that is configured to accept messages from all remote IP addresses through SMTP port 25   This connector typically accepts connections from all IP address ranges. The usage type for this connector is Internal. This connector is created automatically during setup. This connector only accepts mail from other Exchange servers that are part of the same Exchange organization. By default, this connector does not accept anonymous submissions.