Configuring postfix to forward all email to a smtp gateway
TweetSetting up the Postfix SMTP server to route all your email to an external SMTP Gateway
Suppose you want all your web servers to locally send all email (maybe from your contact forms, or whatever) to a real smtp gateway. If you're running postfix as your MTA, this is quite easy to achieve.
In your main.cf file (usually /etc/postfix/main.cf or /usr/local/etc/postfix/main.cf), specify your transport maps:
And in your transport file (usually /etc/postfix/transport or /usr/local/etc/postfix/transport), specify your gateways per domain.
This allows you to specify with regular expressions which emails go where. In this case, an asterisk specifies every domain (the transport file allows very complex setups, this is of course an extreme and trivial example):
Then invoke postmap to regenerate the transports db, and reload postfix:
All local emails will be routed to another SMTP Server
That should do it. All email generated in this host should now be forwarded to the smtp gateway. Remember to configure your smtp gateway to accept mail from all the hosts that will forward emails to it.