How can I forward (or proxy) mail to different smtp servers depending on the To address?
I've got one machine with an SMTP (postfix) server listening on port 25. I want to use Lamson (http://lamsonproject.org/) to handle some incoming mail and some mail I want to have postfix to handle.
My idea is to setup Lamson to listen on a different port, let's say localhost:10025. I then setup postfix to catch all mail by listening on port 25.
How do I configure Postfix to proxy certain mail to Lamson on 10025 and handle all other mail itself?
Best Answer
Postfix is extremely flexible (and therefore, complex) in its configuration, so there are various ways to achieve this. The simplest way would probably be to use a
transport(5)
table.First, enable the use of a transport table in postfix:
You'll also have to make sure that Postfix accepts mails for the addresses that will be handled by Lamson. Have a look at
permit_auth_destination
for the rules Postfix will apply to determine valid recipient addresses. For the following example, assuming "example.com" is a domain not otherwise known to Postfix, it's probably easiest to simply add it as relay domain:Then, create an appropriate table. E.g. to redirect all mail for the domain "example.com" as well as mail for "user@mydomain.org" to your local Lamson listening at port 10025:
After that (and then once after every update to the transport table file) don't forget to run:
This should get you going. Be sure to read the
transport(5)
man page, which will give you more ideas on how to use this powerful facility.