Skip to content

Instantly share code, notes, and snippets.

@javierwilson
Created May 3, 2014 17:18
Show Gist options
  • Save javierwilson/264370c36971d6e5225a to your computer and use it in GitHub Desktop.
Save javierwilson/264370c36971d6e5225a to your computer and use it in GitHub Desktop.
Delete mail in queue from: or to: specific e-mail address
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: $0 [email protected]"
exit
fi
rcpt=$1
QIDS=`mailq | grep -B1 "$rcpt" | grep '^[a-z]' | awk '{print $1}' | sed 's/\*$//'`
for q in $QIDS
do
echo "Deleting $q"
qtool.pl -C /etc/mail/sendmail.cf -d /var/spool/mqueue/$q
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment