Search
Tags for How-To Copy all in- and outgoing email of a certain domein with Postfix and Z-Panel

How-To Copy all in- and outgoing email of a certain domein with Postfix and Z-Panel

This instructions tells you how to make a copy of in- and outgoing emails from a certain domain server running Postfix and Z-Panel.

Case

There are multiple domains on a (Z-Panel)server running multiple websites and email from different customer. One customer wants a copy of in- and outgoing email for 3 domains sent to a special email address.

More than one main.cf file

On a system with Z-Panel there are more than one main.cf files. Do be precise there are 7.

/etc/postfix/main.cf
/etc/zpanel/configs/postfix/main.cf
/etc/zpanel/panel/etc/build/config_packs/centos_6_2/postfix/conf/main.cf
/etc/zpanel/panel/etc/build/config_packs/centos_6_3/postfix/main.cf
/etc/zpanel/panel/etc/build/config_packs/ubuntu_11_10/postfix/conf/main.cf
/etc/zpanel/panel/etc/build/config_packs/ubuntu_12_04/postfix/main.cf
/usr/lib/postfix/main.cf

You only need to modify one of them and that is /etc/postfix/main.cf . Forget oll the others.

Copy / Forward All email (from all domains, not what you want)

Postfix has the possibility to send a copy of all email to a specific email address. This means that all email from an to all email accounts on all domains is forwarded.
This can simply be don by adding this line in /etc/postfix/main.cf
always_bcc = administrator@example.com
This is not an option if you have different customer with different domains on the server.

Copy / Forward all email from specific domain

This give you the possibility to forward email from only one domain (or as many if you want).

Add this lines in /etc/postfix/main.cf

sender_bcc_maps = hash:/etc/postfix/sender_bcc
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc


Create the this two files: /etc/postfix/recipient_bcc and /etc/postfix/sender_bcc
touch /etc/postfix/sender_bcc
touch /etc/postfix/recipient_bcc



Edit both files by adding line like this:
@domain.com detective@example.com
@domain.eu detective@example.com
@domain.nl detective@example.com

Where @domain.com is the domain you want the email forwarded from and detective@example.com the email address where a copy must be send to. Do this in both file. recipient_bcc is for incoming and sender_bcc for outgoing email.

Create the Postfix lookup tables

Before Postfix can do something with it you have to make the Postfix lookup tables. You have to do this every time you make changes in /etc/postfix/sender_bcc or /etc/postfix/recipient_bcc.

postmap /etc/postfix/sender_bcc
postmap /etc/postfix/recipient_bcc

This creates the following files.
/etc/postfix/recipient_bcc.db
/etc/postfix/sender_bcc.db

Restart postfix

Now restart Postfix and your done.

postfix reload

Note

It's also possible to forward only email from one user. In that case add the recipient to the sender_bcc and recipient_bcc file like this:

Post new comment
The content of this field is kept private and will not be shown publicly.
CAPTCHA
Deze vraag is om te controleren of u een persoon bent. Di is om spam berichten tegen te gaan.