Pages

Welcome to My Blog

This is to share my IT experience with friends all around the world.
I have been working in Linux Fedora Systems for more than 8 years. Its fun to share knowledge and learn..
As everyone knows when a problem arises in your systems "googling" is the way that many depend on..

All the posts here are my working experiences during my working life.. So you can count on it..

I have added the references where I got help in solving IT issues


Tuesday, December 18, 2018

Mail Status Report for Postfix Mail Service in CentOS7

This is a direct and simple task. We really want to see the details of mail service by analysing the maillog daily. It gives a clear picture of what happened during the time period. The system ppl and marketing ppl may use it for customer clarifications.
We have enabled mail log statistics reporting tools in CentOS 6/7 servers which run Postfix as the mail agent.
Please follow the steps here:

1. Installing mail log analyser

yum install  postfix-perl-scripts

This will install required script with perl modules. Just verify the proper work of it by running the command

perl /usr/sbin/pflogsumm -d yesterday /var/log/maillog

which gives the details of the mail delivery of yesterday.

2. Enable automated reporting
You need to install 'nail' tool to send automated emails. Use this tool to send the output of the above command to required recipients.

e.g
/usr/bin/perl /usr/sbin/pflogsumm -d yesterday /var/log/maillog | /usr/bin/nail -s "Mail status - company mail service `date --date="yesterday" +%d\ %B\ %Y`" -c systems@company.lk manager@company.lk

According to above example, a mail with yesterday mail status will be received by systems@company.lk and manager@company.lk

You can include the above command in a file located in where ever you prefer and change the mode to 770 for the script file enable executable mode.

 e.g. chmod 770  /home/<your_home_directory/mail_stats

In root crontab, include an entry to execute the script file at a preferred time

crontab -e

E.g.

30 12 * * * /home/your_home_directory/scripts/mail_stats

No comments:

Post a Comment