Shell script to display recipient email from message id – postfix

#!/bin/bash
if [ -z "$1" ];then
echo "Usage:$0 "
else
abuse=`echo $1| cut -f2 -d.`
log_seq=0
if [ "$log_seq" -le 1 ];then
log_file=/var/log/maillog
else
log_file=/var/log/maillog/$log_seq
fi
cat $log_file | grep $abuse | grep -w relay | awk '{print $7}' | sed 's/.*<\(.*\)>.*/\1/'
fi

You may also like...