Remove a single mail from the postfix queue on Linux

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, March 01, 2012

Follow me on Twitter as @mattiasgeniar

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  generic-bounces@source.be
(lost connection with [mailserver] while sending end of data -- message may be sent more than once)
                                         user@somedomain.be

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.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.