Need Help - Postfix Maybe...

Started by Melbosa, April 09, 2012, 01:32:02 PM

Previous topic - Next topic

Melbosa

Hi,

I need a solution quickly to solve this problem scenario:

I have a client with multiple email local servers.

I need to setup a gateway for SMTP that decides where to route email locally based on email address.  I believe this can be achieved through a postfix transport map install, but I haven't been able to get it to work at all.

So what I want to do is:

* Setup an SMTP Gateway to accept email from world
* Decide based on email address which email server to relay the mail too
* Kicker is the email addresses could be same domain different email server (so joe@company.com goes to server A and susan@company.com goes to server B)

Anyone any good with postfix?
Sometimes I Think Before I Type... Sometimes!

Melbosa

Doh minutes after posting I fixed my issue... crazy!
Sometimes I Think Before I Type... Sometimes!

Lazybones

Maybe you should post a sanitized config so the rest of us can use your solution in the future. ;)

Melbosa

So to set this up with Postfix:
* Install Linux Distro of Choice
*Setup Postfix (do your proper changes to the postfix main config) and disable Sendmail
* Test Postfix can receive email
* Setup relay domains you want:
postconf -e 'relay_domains = yourdomain.ca, yourotherdomain.ca
* Enable Transport Maps and setup your transport file (usually /etc/postfix/transport) to point at your smtp servers (at the end of the file):
yourdomain.ca          smtp:[192.168.1.5]
yourotherdomain.ca     smtp:[192.168.1.10]

* OPTIONAL: If you want to relay based on email address, add it before the above lines in the transport file:
user@yourdomain.ca          smtp:[192.168.1.5]
user@yourotherdomain.ca     smtp:[192.168.1.10]

* Most of the time you need to create a postmap after editing your Transport File:
postmap hash:/etc/postfix/transport
* For every edit, you must reload your postfix:
postfix reload


Point your inbound SMTP at this new install and your golden!
Sometimes I Think Before I Type... Sometimes!

Melbosa

As you can see with the above, if you have users split between servers but same domain (or migrating to new email system like I was doing), you can easily accomplish this by:

* put your users in your transport file, but point them at the new server as you move them (if say doing a migration):
user1@yourdomain.ca      smtp:[192.168.1.5]
user2@yourdomain.ca      smtp:[192.168.1.5]


* but have a catch-all for any not listed pointing at your old server or any not handled:
yourdomain.ca      smtp:[192.168.1.10]

It is a top-down search so make sure your catch-all is at the end.  In this example, email to user1 and user2 go to server 192.168.1.5 and email to everyone else goes to server 192.168.1.10 for the domain yourdomain.ca
Sometimes I Think Before I Type... Sometimes!

Lazybones