sender based routing with exchange 2013 and hMailserver

Exchange (2013 and other) support sender based routing only through 3rd party software such as described here or here or here. Too complicated or costly I chose to follow this post by using free hMailserver to achieve this:

  • fresh install
  • no domains setup
  • Settings > Protocols: check only SMTP
  • Settings > Protocols > SMTP > Routes
    #1 Domain: default (this is just for naming purposes)
    Target SMTP host: our.default.mailgateway.xyz
    Connection security: STARTTLS (because why not)
    When sender matches: local
    When recipient matches: remote
    (those two settings should have no effect what so ever)

    #2 Domain: newgateway
    Target SMTP host: our.new.mailgateway.xyz
    settings as above
  • Rules:
    #1 Name: new-gatway
    Criteria: From contains newdomain.xyz
    Action: Send using route [newgateway]
    Action: Stop rule processing

    #2 Name: default
    Criteria: Message size > 0
    Action: Send using route [default]
    keep this rule at the end of the list, it affects every mail that has not been routed by a previous rule.
  • IP Ranges:
    Delete existing, create one new:
    Name: local
    priority: 5
    Lower and Upper IP: the local IP address of the server
    (our machine is behind NAT, this is important since we basically turn this hMailserver into an open relay)
    Allow connections: SMTP (nothing else)
    Allow deliveries from: ALL
    Require SMTP authentication from: NONE
  • TCP/IP ports:
    delete all except SMTP, change to custom port (e.g. 1125, 26 or such)

then change your probably only exchange send connector. I could not change the port via ECP so I used PowerShell:

Get-SendConnector
Set-SendConnector SMTP-Connector -SmartHosts “your local server IP” -Port ##your custom port see above##

This setup works for us and should work for small sized installations.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s