我的脚本有效。它将mailq
中的前三个邮件ID保存在临时文件中,但之后我只收到错误。
for QID in $(/opt/zimbra/postfix/sbin/mailq | grep -E "^[0-9A-F]{10,12}\ "|cut -f1 -d' '); do
/opt/zimbra/postfix/sbin/postcat -c /opt/zimbra/postfix/conf -q ${QID}|grep -q '$1' &&
TEMP=`(mktemp /tmp/$1.XXXX)`
echo ${QID} >> $TEMP
done
echo "All mail in quene from IP $1 is listed in file: $TEMP"
./test.sh 127.0.0.1
./test.sh: line 1: $TEMP: ambiguous redirect
./test.sh: line 1: $TEMP: ambiguous redirect
./test.sh: line 1: $TEMP: ambiguous redirect
./test.sh: line 1: $TEMP: ambiguous redirect
./test.sh: line 1: $TEMP: ambiguous redirect
./test.sh: line 1: $TEMP: ambiguous redirect
来自IP 127.0.0.1的队列中的所有邮件都列在文件:/tmp/127.0.0.1.s7oN