#!/bin/sh # # /usr/local/sbin/localshowmailreceived # Copyright 2007 Jonas Smedegaard # # $Id: localshowmailreceived,v 1.3 2007-09-27 21:43:37 jonas Exp $ # # List recently received emails # # TODO: Handle other indicatiors than AMaViS # logfiles="${logfiles:-1}" maildomain=$(if [ -r /etc/mailname ]; then head -n 1 /etc/mailname; fi;) find /var/log -name 'mail.log*' | sort -nr -t. -k3 | tail -n "$logfiles" | xargs zcat -f \ | egrep -- ' -> <'"$1"'@'"$maildomain" \ | sed 's/^\(.\{15\}\) [^)]*) \([^,]*\), [^]]*] \([^ ]*\) -> .*Message-ID: \([^>,]*>\?\).*/\1 \3 (\4) \2/'