This article will show you how to copy incoming mail to another mail server using the blind carbon copy (BCC) feature in Postfix. This capability is useful for backup, archive or disaster recovery purposes.

Edit main.cf1. Edit the file /etc/postfix/ and add the lines below.
recipient_bcc_maps = pcre:/etc/postfix/backup_bcc.pcre
transport_maps = hash:/etc/postfix/transport
smtp_generic_maps = pcre:/etc/postfix/generic.pcre
Edit backup-bcc.pcre
2. Create the file /etc/postfix/backup_bcc.pcre containing
/^(.*)@acme\.local$/ $1@backup.invalid

which tells Postfix to BCC emails to the domain backup.invalid.

Email forBCC to
Edit transport
3. Edit the file /etc/postfix/transport and add the line below.
backup.invalid smtp:[]

Replace the IP address with the IP address of your backup mail server.

Next, type in the command below to convert it to a database file.

postmap /etc/postfix/transport

This tells Postfix to send all emails for the domain backup.invalid to the specified mail server.

Edit generic.pcre
4. Create the file /etc/postfix/generic.pcre containing
/^(.*)@backup\.invalid$/ $1@acme.local

which tells Postfix to change the email address back to the original recipient before sending it out.

BCC toEmail for
Service Configuration5. Restart the Postfix or MailScanner service if you have installed it. Learn how to start and stop services here.
NoteIf you encounter any problems, check the log file at /var/log/maillog.

Visit the forum to ask for help or to give a comment.

Posted on 12/12/2009 and last updated on 5/9/2010
Filed under Backup , Postfix