execute command for select emails with postfix

you can use procmail to filter e-mails according to subject. Then you will have the option to run any command in response to the e-mail, or you can leave it untouched and have it delivered to your mailbox.

You can read procmail quickstart which is an excellent article.

To enable procmail usage, place a ".forward" file under your user's home directory, and make its content like this

| "/usr/bin/procmail"

Then write your procmail "recipes" under ~/.procmailrc

Note that most other filtering options (like sieve) will not allow you to execute arbitrary commands.


try this - put into /etc/aliases:

username: "|/your/script"

and then run

postalias /etc/aliases

when e-mail comes to [email protected] /your/script will be executed and will receive content of message [ with all headers ] into stdin. i'm affraid you'll have to check the subject by your self.


If you only want some emails to a given address to trigger a command (based on their subject or whatever), and others to be delivered as normal email, you'll have to use procmail as described above. Using /etc/aliases will cause every single message sent to that address to invoke the specified command (and won't be delivered via the local delivery mechanism).