How to Record All Incoming & Outgoing Mails To Seperate Email Addresses In Postfix

In this post I am going to explain how to record/archive all the incoming and outgoing emails from a postfix system to two different email addresses.

I have a CentOS 6.3 x86_64 Minimal install system. In CentOS 6, postfix is installed and will be running by default.

1) Working DNS Server : Incase you dont know how to configure, please look at this link to configure BIND DNS Server

2) Postfix must be installed. Incase its not installed then
[root@mail ~]# yum install postfix -y

Edit the Postfix Configuration file
[root@mail ~] # vim /etc/postfix/
myhostname =
mydomain =
myorigin = $mydomain
inet_interfaces = $myhostname, localhost
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks =,
mynetworks_style = subnet

sender_bcc_maps = hash:/etc/postfix/outgoing
recipient_bcc_maps = hash:/etc/postfix/incoming

Create two users inmails and outmails and assign passwords for them
[root@mail ~]# useradd inmails
[root@mail ~]# echo "redhat" | passwd --stdin inmails
[root@mail ~]# useradd outmails
[root@mail ~]# echo "redhat" | passwd --stdin outmails

Create two file inside the postfix configuration directory
[root@mail ~]# vim /etc/postfix/incoming

[root@mail ~]# vim /etc/postfix/outgoing

Create the postfix lookup table using the postmap command. Postmap is utility program that will convert /etc/postfix/incoming to /etc/postfix/incoming.db in Berkley DB format, so that Postfix can access the data faster.
[root@mail ~]# postmap /etc/postfix/incoming
[root@mail ~]# postmap /etc/postfix/outgoing

Restart the postfix service and make service available during startup
[root@mail ~]# service postfix restart

Test the configuration by sending a mail to any user on the system it will recorded in inmails user mailbox and outmails user mailbox as well.

Post a Comment

Mới hơn Cũ hơn