Mail in Postfix Queue Redirect to another Pecipient


Postfix mail queue gets email stuck, the email should now be redirect to another recipient! Such a scenario can occur if no emails can be delivered to the original recipient address, for example when the mailbox space limit is reached, or the server responds with an error or there are the server is unreachable.

Here it can be helpful to temporarily send the email to another recipient. The tutorial shows the steps for delivering an e-mail remaining in the Postfix queue to an alternative recipient.

How to redirect queued mail to recipient

First, you look for the queue ID of the e-mail in the Postfix queue, which you want to redirect to another recipient address.

$ postqueue -p | grep '' -B 2

  The parameter -B 2 outputs two additional lines before the parse.

The output can look similar to the following.

BCD2C3035D31!   37023 Thu Feb 17 08:59:55
        (connect to[]:25: Connection timed out)

Here an e-mail was sent to which I want to deliver to a different address. The queue ID is BCD2C3035D31 which we need.

Alternatively, you can simply listing emails in the Postfix queues.

$ mailq

To prevent Postfix from trying to deliver the deffered email in the meantime, we set it to on hold with the -h option.

$ postsuper -h BCD2C3035D31
postsuper: BCD2C3035D31: placed on hold
postsuper: Placed on hold: 1 message

  The e-mails are not deleted with on hold. The exclamation mark (!) indicates that the message is on hold.

Now you extract the e-mail and save it to a temporary file.

$ postcat -qbh BCD2C3035D31 > /tmp/email.eml

Now that the email is extracted, you can send it to a different recipient than the original.

$ sendmail -f < /tmp/email.eml

The e-mail will be sent from to

Search the Postfix deffered queue for pending emails.

$ postqueue -vp

After the delivery to the new e-mail address has been confirmed, the e-mail can be removed from the Postfix queue.

$ postsuper -d BCD2C3035D31
postsuper: BCD2C3035D31: removed
postsuper: Deleted: 1 message

Delete the temporary /tmp/email.eml file.

$ rm -f /tmp/email.eml

Postfix helpful commands

  Hint! To show Postfix queued e-mail contents.

$ postcat -vq BCD2C3035D31

Release mail that was put „on hold“.

$ postsuper -H BCD2C3035D31
postsuper: BCD2C3035D31: released from hold
postsuper: Released from hold: 1 message

Flush the queue, attempt to deliver all queued mail.

$ postqueue -f

To remove all e-mails in the Postfix deferred queue.

$ postsuper -d ALL deferred

Postfix Mail Queue Redirect Conclusion

As shown in this tutorial, it is possible to set e-mails from the Postfix mail queue to Hold, temporarily redirect them to other recipients, and remaining e-mails can also be removed from the queue for system hygiene.

Wie hilfreich war dieser Beitrag?

Klicke auf die Sterne um zu bewerten!

Durchschnittliche Bewertung 5 / 5. Anzahl Bewertungen: 4

Bisher keine Bewertungen! Sei der Erste, der diesen Beitrag bewertet.

Ein Gedanke zu „Mail in Postfix Queue Redirect to another Pecipient“

  1. Thanks. I changed providers and they have no smtp relay, so a bunch of redirected email was stuck in the outbound queue.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert