PROJET AUTOBLOG


Shaarli - Librement Shaarli

Site original : Shaarli - Librement Shaarli

⇐ retour index

Postfix mail queue: deliver e-mail to an alternate address

lundi 24 juin 2019 à 16:21
Find the mail ID in postfix

$ postqueue  -p | grep 'm@ttias.be' -B 2 | grep 'keyword'
42DA1C0B84D0    28177 Tue Aug  2 14:52:38  thesender@domain.tld

In this case, a mail was sent to me and I'd like to have that be delivered to a different address. The identifier in the front, 42DA1C0B84D0 is what we'll need.

Mark the postfix queue item as 'on hold'
To prevent Postfix from trying to deliver it in the meanwhile.
$ postsuper -h CF452C1239FB
postsuper: CF452C1239FB: placed on hold
postsuper: Placed on hold: 1 message

Don't worry, your mail isn't deleted.
Extract that email and save it to a temporary file. If you're paranoid, don't save to /tmp as everyone can read that mail while it's there.
$ postcat -qbh CF452C1239FB > /tmp/m.eml

Now, to resend.
Send queued mail to different recipient
Now that you've extracted that e-mail, you can have it be sent to a different recipient than the original.
$ sendmail -f $sender $recipient < /tmp/m.eml
Permalink