Skip to content

Instantly share code, notes, and snippets.

@mick-shaw
Last active June 24, 2017 17:06
Show Gist options
  • Save mick-shaw/814c21d1ef9e48a27fa6 to your computer and use it in GitHub Desktop.
Save mick-shaw/814c21d1ef9e48a27fa6 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script will prompt for sender domain and then purge the mail queue
# Requires qtool.pl
echo "Type the sender domain you would like to purge, followed by [ENTER]:"
read domain
echo "Got it. I'll purge all messages from $domain"
QIDS="$(mailq | grep -B1 $domain | grep '^[a-z]' | awk '{print $1}' | sed 's/\*$//')"
for q in $QIDS
do
/usr/local/bin/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