Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Forked from mick-shaw/Clear MailQueue Script
Created June 24, 2017 17:06
Show Gist options
  • Save jpluimers/497e7f55b09767cf65006696c7b9fc14 to your computer and use it in GitHub Desktop.
Save jpluimers/497e7f55b09767cf65006696c7b9fc14 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