Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to pass emails from specific senders to a shell script via procmail.

Here's my original starter script:


! `/home/foouser/`

This works fine but it applies to all messages going to foouser. I'd like to set a condition so it only sends the message to the script if the email is from specific people on a whitelist. Is this possible?

share|improve this question
Incidentally, are you sure the delivery syntax is what you intend? This will try to forward the message to the address which is the output of the script /home/foouser/ The script does receive the message as its standard input, but if your intent is to just pass the message to the script, the regular syntax for that is to drop the backticks and use a pipe character instead of an exclamation mark; i.e. | /home/foouser/ – tripleee Aug 15 '12 at 11:14
@tripleee Interesting. Yes, that's exactly what I'm trying to do. I grabbed the syntax from somewhere else online. Is there any other major difference/vulnerability to using the backticks? I'm wondering if there would be an issue if the email had potentially dangerous content in it (e.g. rm -fr /). I've already hardened the script to protect against this but what about procmail? – Mike B Aug 15 '12 at 15:02
If you don't intend to forward the message, definitely don't use the forwarding syntax. As far as security considerations are involved, nothing you have shown us indicates that the contents of the email are going to be evaluated as code; but if does something like that internally, that's a genuine and serious concern, and you should definitely have an expert audit it. – tripleee Aug 15 '12 at 17:56
up vote 3 down vote accepted

Sure, the point of procmail is to filter messages ;-)

* ^From:(.*\<)?(alice@example\.org|bob@example\.com)\>
! `/home/foouser/`

Edit: Fix the missing asterisk on the condition line, and reinstate the (admittedly weird) action line.

share|improve this answer
You sir, are my hero. Thank you. – Mike B Aug 14 '12 at 6:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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