Remove a single mail from the postfix queue on Linux

Oh Dear monitors your entire site, not just the homepage. We crawl and search for broken pages and mixed content, send alerts when your site is down and notify you on expiring SSL certificates.

Start your free 10 day trial! »

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 "" -B 2 -A 1
B3D7B2601F8A    56352 Tue Feb 28 17:19:58
(lost connection with [mailserver] while sending end of data -- message may be sent more than once)

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.