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.

Pre-requesites:
1) Working DNS Server : Incase you dont know how to configure, please look at this link to configure BIND DNS Server http://easylinuxtutorials.blogspot.in/2011/11/setting-up-dns-server-in-rhel-6.html

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/main.cf
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = $myhostname, localhost
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.124.0/24, 127.0.0.0/8
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
@example.com          inmails@example.com

[root@mail ~]# vim /etc/postfix/outgoing
@example.com          outmails@example.com

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.

Nhận xét

Bài đăng phổ biến từ blog này

CLEANING UP THE ZABBIX DATABASE

Configuring DHCP Relay service on the FortiGate unit

WAN link load balancing