Jump to: navigation, search
MithiWiki Home > ConnectXf Home > ConnectXf Administration > Configuration > How to delete mails from Postfix Queue


HowTo Icon.png
How To
Product ConnectXf
Version All
Applies to Administrators
Level Advanced


How to delete spam mails from Postfix Queue

Requirement/Situation

Due to an internal spam attack, one of my postfix queue (typically the outgoing queue) has got lots of junk messages, which are taking very long to send and are clogging up the queue. These are typically sent to invalid domains.

Cleaning the postfix queue (for Connect Xf versions 3.8+)

  • Find the ids of the junk mail from the postfix queue. For this you would need to search the queue based on the domain name of the recipient of these junk mail.
sudo postqueue -p -c /etc/connectxfpostfix/postfix-<name of queue>/ | grep <name of spam domain name> -i | cut -d ' ' -f 1 | sed 's/*$//g' > cleanoutqueue.sh
  • Creating a script to delete the spam mails in postfix queue.
sudo cat cleanoutqueue.sh |awk '{print "sudo postsuper -c /etc/connectxfpostfix/postfix-<name of queue>/ -d " $1}'> cleanout.sh 
  • Give the executable permission to script.
chmod +x cleanout.sh
  • Run the script.
sh cleanout.sh

Cleaning the postfix queue (for Connect Xf versions before 3.8)

  • Find the ids of the junk mail from the postfix queue. For this you would need to search the queue based on the domain name of the recipient of these junk mail.
sudo postqueue -p -c /etc/postfix-<name of queue>/ | grep <name of spam domain name> -i | cut -d ' ' -f 1 | sed 's/*$//g' > cleanoutqueue.sh
  • Creating a script to delete the spam mails in postfix queue.
sudo cat cleanoutqueue.sh |awk '{print "sudo postsuper -c /etc/postfix-<name of queue>/ -d " $1}'> cleanout.sh 
  • Give the executable permission to script.
chmod +x cleanout.sh
  • Run the script.
sh cleanout.sh