I may well be on the wrong track here with what I'm trying to do, so I'd appreciate any advice.

Is it possible to pipe email to a script (which I have working), and then have Postfix forward it on to its original recipient using transport_maps, virtual_alias_maps or some other Postfix type thing?

Looking at the Postfix mailflow diagram, the answer is probably no because Pipe does not then go on to re-queue the message. Therefore my question is, if not, then what is the best way of doing what I am trying to do? Should my piped script (which basically dumps the email content to a text file) also be in charge of sending this on using something like sendmail? Or is there a better way?

Many thanks


You can use feature always_bcc. Add this parameter in main.cf.

always_bcc = mypipe@example.com

Then you can put mypipe@example.com to the alias file e.g /etc/aliases

mypipe: "|/path/to/myscript.sh"

Don't forget to postalias the alias file.

Note: domain example.com should be a local domains, because pipe must be in local classes domain


If your case is sender-dependent script or recipient-dependent script, you can use the variations of always_bcc, they are recipient_bcc_maps for recipient-dependent script or sender_bcc_maps for sender-dependent script

|improve this answer|||||
  • That's an interesting idea. It would work great if I always wanted to bcc to a particular address, but my aim is to have various email accounts each using a different piped script (again, working), and then have them forwarded to the original recipients. Any further ideas? – Tom May 7 '14 at 15:58
  • That sounds more like it. Just left work but can't wait to get home and give it a try. Sorry I can't increase your answer rating as a new user :-( – Tom May 7 '14 at 16:10
  • Thanks a lot for that, it worked a treat. I still had to mess about with transport and virtual a bit because the recipient to BCC had it's mailbox on another (Exchange) server, which I didn't specify. I'm amazed more and more each day by what Postfix can do, and I get the feeling I've only just scratched the surface. Thanks again! – Tom May 8 '14 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.