Forward mails to specific servers (Postfix transport)

I was struggling to efficiently forward the OpenVZ hosts local e-mails to an private VE (MTA) since that system is bound to an IP address from a private range (192.168.x.x). Basically, I just wanted to have all mail for to be routed to that “internal” mail server. In the end, postfix manuals led me to a simple solution. Thus, add the following lines to the postfix configuration files.


transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport  smtp:

To make sure your changes are being applied, run the following commands

# postmap /etc/postfix/transport
# postfix reload

The above lines cause postfix to forward mail targeting to the MTA with IP Make sure, the recipient mail server does accept incoming connections (I had to adjust the postgrey whitelist)

Amavisd Passed CLEAN Mails

Ever wanted to know what mails cleanly passed your postfix/amavis installation? Use the following statement to generate an overview for the current day.

prompt# TODAY=`date | perl -pe 's/....(......).*/$1/'` egrep "$TODAY.*Passed CLEAN" /var/log/maillog | perl -pe 's/.*(..:..).* (<.*>) ->.*Hits: (.*), size.*/$1 Hits: $3 $2/' | grep -v "Hits: -"

16:23 Hits: 2.957