When running Postfix, it’s very easy to delete an e-mail from an existing mail queue. You may want to do this if a certain e-mail is bouncing back and forth between the mailservers with “lost connection with [mailserver] while sending end of data -– message may be sent more than once” messages. First, a few basics.
To show your entire mailqueue, type the following at a bash prompt.
# postqueue -p | more
To find a specific e-mail sent to a certain e-mail address, use grep.
# postqueue -p | grep "somedomain.be" -B 2 -A 1 B3D7B2601F8A 56352 Tue Feb 28 17:19:58 firstname.lastname@example.org (lost connection with [mailserver] while sending end of data -- message may be sent more than once) email@example.com
The first line of your result will indicate a message ID (in this case “B3D7B2601F8A”). To delete that e-mail, run the following.
# postsuper -d B3D7B2601F8A postsuper: B3D7B2601F8A: removed postsuper: Deleted: 1 message
That you’ve just identified the mail you wanted to remove and removed it from the Postfix queue.