Proxy mail to different smtp server with Postfix
Solution 1:
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:
/etc/postfix/main.cf:
transport_maps = hash:/etc/postfix/transport
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:
/etc/postfix/main.cf:
relay_domains = example.com
Then, create an appropriate table. E.g. to redirect all mail for the domain "example.com" as well as mail for "[email protected]" to your local Lamson listening at port 10025:
/etc/postfix/transport:
example.com smtp:127.0.0.1:10025
[email protected] smtp:127.0.0.1:10025
After that (and then once after every update to the transport table file) don't forget to run:
$ postmap /etc/postfix/transport
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.