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 example.com 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.

/etc/postfix/main.cf

transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport

example.com  smtp:192.168.1.1

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 example.com to the MTA with IP 192.168.1.1. 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: -"

Output:
16:23 Hits: 2.957