Home | Comics | wishlist | Impressum | Datenschutzerklärung |

How to archive all mail retaining the original envelope recipient


I want to archive all mail going in and out, but I want to retain the original envelope recipient.


Use regexp/pcre based recipient_bcc_maps to preserve the original recipient:
# bcc addresses are in internal form (de-quoted). 
if !/@bcc\.invalid$/ 
   /^(.*)/   ${1}@bcc.invalid 
note: if/endif is only supported in Postfix 2.2 or later -- with Postfix 2.1 you'd have to use:
# bcc addresses are in internal form (de-quoted). 
/^(.*@your\.domain)/   ${1}@bcc.invalid 
In main.cf add:
recipient_bcc_maps = pcre:/etc/postfix/backup_bcc.pcre
Then route the "@bcc.invalid" mail to a suitable transport (e.g. virtual). To do that, add in main.cf:
virtual_mailbox_domains = bcc.invalid

virtual_mailbox_base = /home/bcc
# mailbox base for our archive

virtual_mailbox_maps = $default_database_type:/etc/postfix/vmbox
# map all addresses in bcc.invalid to a single mailbox

virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
# uid:gid for our archive
In /etc/postfix/vmbox you have:
backup@bcc.invalid  Maildir/
or, if you want to use an mbox instead of a Maildir, use:
backup@bcc.invalid  mbox
with no traling slash!

Regular housekeeping

# sometimes we clean /home/bcc
5 1 * * * /usr/bin/find /home/bcc/20??-??-?? -depth -type d -ctime +28 -exec rm -rf {} \;

# we rotate /home/bcc daily
59 23 * * * rotate_it

rotate_it being a little script:


mkdir /home/bcc/Maildir.new 
chown 1000:1000 /home/bcc/Maildir.new
chmod 700 /home/bcc/Maildir.new
mv /home/bcc/Maildir /home/bcc/`/bin/date -I` && mv /home/bcc/Maildir.new /home/bcc/Maildir

That's it.

© by Ralf Hildebrandt
This document contains links to external information sources that I do neither monitor nor control. I explicitly disclaim any liabilities in respect to external references.
You are getting this document without any guarantees. Any methods shown above are meant as demonstration and may be wrong in some place. You may damage your system if you try to follow my hints and instructions. You do this at your own risk!

This file was last modified 17. Jan 2007 by root