OK, there are better ways to archive emails than this and a better title for this post is probably more along the search terms that I used: postfix send a copy of an email to another address. The idea here is that any email that is caught by Postfix and matches either a sender or recipient address is bcc'd to another account, this is probably quite a dark grey legal area (almost black) because it is the equivalent of spying if the person who's account that you're hijacking doesn't know that you are doing this. To that end, this is only a way to keep a backup of emails somewhere like gmail. Some of this information came from Postfix: send a copy of the e-mails send by a specific user and the rest of it came from http://www.postfix.org/postconf.5.html#recipient_bcc_maps
You could do this as an LDAP query, but I've settled for a more mundane approach and am simply using hash tables.
mailbot:/etc/postfix# vi /etc/postfix/bcc_maps
spam@minigeek.org spam@localdomain.localhost
All mail that goes spam@minigeek.org will have a bcc sent to spam@localdomain.localhost (as you can guess, this won't work but you could substitute @gmail.com).
Now, you need to create the hash map....
mailbot:/etc/postfix# postmap /etc/postfix/bcc_maps
And tell postfix about it:
mailbot:/etc/postfix# vi /etc/postfix/main.cf
# Don't forget to postmap /etc/postfix/bcc_maps to create the db
sender_bcc_maps = hash:/etc/postfix/bcc_maps
recipient_bcc_maps = hash:/etc/postfix/bcc_maps
In this situation, I've used the same maps for both senders and recipients but you can do anything you want - sender is messages sent via Postfix (from address) and recipient is the reciever (to address).
Now all you need to do is to reload the Postfix conf:
mailbot:/etc/postfix# /etc/init.d/postfix reload
Reloading Postfix configuration...done.
mailbot:/etc/postfix#
One thing to take note of, it's not possible to send the bcc to more than one people (unless you use an alias), so don't even bother! If you don't care who the email goes to/comes from and you just want a copy of all the mail saved, then you can simply edit main.cf:
mailbot:/etc/postfix# vi /etc/postfix/main.cf
always_bcc=bcc@localhost.localdomain
and reload the postfix conf:
mailbot:/etc/postfix# /etc/init.d/postfix reload
Reloading Postfix configuration...done.
mailbot:/etc/postfix#
Popularity: 80% [?]


Thanks for the trackback