Monitoring All Incoming and Outgoing Mails in Postfix

 

Hi Friends ,

This is very important to monitor all sending or receiving mails in a organization, For Monitoring May be You have to configure on boss email-id or any other Admin what ever.

So I am going to post “How to forward a bcc copy to given email-id (as per your requirement which you want to use for monitor) whenever any user sends email to anyone or receive from anyone that you can define.

monitoring

Check Postfix mail Server :-

[root@sahil ~]# postconf -d | grep mail_version

mail_version = 2.6.6 <==== I am using postfix 2.6

milter_macro_v = $mail_name $mail_version

We have to define some parameters in /etc/postfix/main.cf file :-

[root@sahil ~]# vim /etc/postfix/main.cf

sender_bcc_maps = hash:/etc/postfix/sender_bcc —> get  a bcc copy to your email id when anyone send a mail to define email address or domains in this file (/etc/postfix/sender_bcc)

recipient_bcc_maps = hash:/etc/postfix/recipient_bcc —–> get  a bcc copy to your email id when anyone receive a mail to define emails address or domains in this file (/etc/postfix/recipient_bc).

wq!

Save and quit

Now define Email-id to receive a bcc copy as per your requirement:-

Create recipient_bcc file :-

[root@sahil ~]# vim /etc/postfix/recipient_bcc

ashraf@sahil.com sahil@sahil.com

#In above if anyone send email to ashraf@sahil.com then a bcc copy will be received to sahil@sahil.com

@xyz.com sahil@sahil.com <— I have other domain (xyz.com) in my mail server , In this example if anyone send email to xyz.com domain all mails of this domain will be received sahil@sahil.com

wq!

Save and quit

Create sender_bcc file :-

[root@sahil ~]# vim /etc/postfix/sender_bcc

ashraf@sahil.com sahil@sahil.com

#In above example if ashraf@sahil.com sends email to anyone then a bcc copy will be received to sahil@sahil.com

@xyz.com sahil@sahil.com <—– In this example if any user of xyz.com domain sends email to anyone then all sanded mails will be received to sahil@sahil.com

wq!

Save and quit

Now create database of file ( /etc/postfix/sender_bcc ) with the help of following command:-

[root@sahil ~]#postmap /etc/postfix/sender_bcc

Also do the same for /etc/postfix/recipient_bcc :-

[root@sahil ~]# postmap /etc/postfix/recipient_bcc

Now Restart postfix :-

[root@sahil ~]# /etc/init.d/postfix  restart

Thats it.

Now try to send or receive email from define email-ids or domains . It will be work 🙂

Hope this will helpful for You !!

Enjoy Linux-Ing 🙂 🙂 🙂

2 thoughts on “Monitoring All Incoming and Outgoing Mails in Postfix”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top