Remove a single mail from the postfix queue on Linux

Tired of the privacy invasion of browsers? Worried about the risk of seeing ads everywhere? Give the Brave Browser a try. All Chrome extensions are compatible. None of the telemetry. Auto-blocks ads and still support content creators like me.

Download the Brave browser now »

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.