Alias pipe to program

Is it possible to forward messages intended for a particular email to the standard input of a program. With postfix this would be handled through an alias that pipes into the program.

Something like this
add line into file: /etc/aliases

issues: "|/usr/local/sbin/mailhandler"

I have the same question. it did not work in my case.

I got it to work by changing mydestination on main.cf but then no other emails were working.

I tried to have both mydomain.com and localhost on $mydestination but that made other emails useless.

don’t think virtual_mailbox_maps virtual_alias_maps can pipe into a program. any idea how can I achieve this?

now I’m thinking to have a separate email server just to pipe emails into a script (which is a stupid workaround).

UPDATE: apparently sieve has a plugin called extprogram that does what I need. but did not manage to get it to work

Has anyone had any luck with this

I am trying to pipe an email alias to a php file for some processing

I can get this done through /etc/aliases but cannot work out how to route an email from mailinabox to one of the local accounts so it can be automatically piped to my php script

G

Did you ever end up figuring this out? Trying to do something similar.

This might help, never tested though:

It’s a bit more work than expected but I managed to get it working.

In addition to adding an alias in /etc/aliases the transport for the user also has to be set to local and the mailbox needs to exist.

Add a mail user as normal.

In /etc/postfix/main.cf find transport_maps. It probably doesn’t exist, so add it, for example transport_maps = hash:/etc/postfix/transport.
/etc/postfix/transport probably doesn’t exist so create this file. The contents are the email user you just added followed by local:

If it’s not working try
newaliases
postmap /etc/postfix/transport
restart postfix service