Fast and dirty parsing of /var/log/mail.log.
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash cat /var/log/mail.log|grep "> -> <"|awk '{print $1," "$2," "$3," "$13," "$15," "$17}'|tr -d ','|while read p; do mid=$(echo $p|awk '{print $6}') sender=$(echo $p|awk '{print $4}') if [ $sender != "Message-ID:" -a $sender != "->" ] then status=$(cat /var/log/mail.log|grep $mid |grep -Eo "status=\w+") echo $p $status fi done |
It shows: date, sender, recipient, mail id, status
1 2 3 4 5 6 7 |
Oct 31 00:34:14 <noreplay@sender.com> <sibbbbl@icccon.bg> EBE5640D38 status=sent Oct 31 00:34:24 <noreplay@sender.com> <sbbbbt@mariccc.org> 1396F40D39 status=sent Oct 31 00:34:24 <noreplay@sender.com> <m.gbbbbieva@cccumen.bg> 3094940D3A status=sent Oct 31 00:34:33 <noreplay@sender.com> <fibbbbi@dicccr.bg> 3957640D3B status=sent Oct 31 00:34:34 <noreplay@sender.com> <sbbbbtli@mccc.bg> 47FE840D3C status=sent Oct 31 00:34:43 <noreplay@sender.com> <bbbbitly@maccc.bg> 61C3440D3D status=sent Oct 31 00:34:44 <noreplay@sender.com> <sitobbbbsi@maccc.bg> 724F340D3E status=sent |