简体   繁体   中英

Delete Mails from Postfix Queue with filter from and to

I try to delete some special mails from Postifx Queue. I want to Filter with "Mail From" and Mail Domain "TO".

I have tried:

mailq|grep 'info@sendingdomain.com'|awk '/ @test\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -

But it don't work.

You can use this bunch of code

#!/bin/bash

[ ! -n "$1" ] && echo "Usage : $0 mail" && exit 1

for mail in $( mailq|egrep '^[A-Z0-9]'|grep "$1"|awk '{print $1}'|sed 's/^\([0-9A-Z]*\).*$/\1/' )
do
    /usr/sbin/postsuper -d $mail
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM