search
top

Postfix archive emails via bcc

Postfix iconOK, 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.

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

And tell postfix about it:

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:

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:

and reload the postfix conf:

4 Responses to “Postfix archive emails via bcc”

  1. Fred says:

    Thanks for the trackback ;)

    Fred did not rate this post.
  2. Tom Dings says:

    Really nice to read these kind of tricks are possible with Postfix. Thanks a lot and have a nice weekend!

    Tom Dings did not rate this post.
  3. Tom Dings says:

    Are you able to contact me please .. When i put a line in the config like this i am not able to use my server anymore as a relaying mail host. Any ideas ?

    Thanks in advance.

    Tom Dings did not rate this post.
  4. Tom Dings says:

    Sorry for all those reactions but POSTMAP did the trick .. Maybe worth to tell the people to use POSTMAP first before anything of your great tricks will work ??

    Tom Dings did not rate this post.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

top