Setting up daily mail reporting using pflogsumm

pflogsumm is a perl script used for postfix mail reporting.

Setup

  • Create directory /var/log/postfixrep
  • Copy pflogsumm into directory /usr/local/bin/pflogsumm
  • Create file /etc/cron.daily as below - change hard-coded email
#!/bin/bash
#
# Daily Postfix Log report
#
TS=$(date +%Y%m%d_%H%M%S);
LOGFILEDIR="/var/log/postfixrep"
LOGFILE="$LOGFILEDIR/pfrep_$TS.txt"
PFLOGSUMM="/usr/local/bin/pflogsumm"
PFMAILINF="/var/log/mail.info"
PFMAILINF="/var/log/mail.log"
REMAIL="admin@example.org"
REPSUB="Postfix Report"
#
$PFLOGSUMM $PFMAILINF > $LOGFILE
cat $LOGFILE | mailx -s "$REPSUB" $REMAIL
#
/usr/bin/find $LOGFILEDIR/pfrep* -mtime +400 -exec rm {} \;
#
exit 0

QR Code
QR Code tech:linux:postfix_report (generated for current page)