Empty Postfix Mail Queue
This command will delete one specific email from the mailq (taken from the postsuper man page)
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "email@address.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -
I use a few scripts that check the status of our servers and email/page me if they don't respond. This led to a problem when I was offline for one reason or another. I would get a ton of messages sent to the postfix queue which would all be sent out when I reconnected to the internet. Deleting the postfix mail Queue is suprisingly easy:
sudo postsuper -d ALL
This command will delete all messages in the Postfix queue. If you need more selective deleting, this can be done as well, use 'man postsuper' to find out all of the available options.
The other thing that helped with this was checking for a local network connection before doing the server checks. This is done with the following.
ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'}L