Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

How do I set up a email whitelist using only procmailrc to protect my kids from unwanted email?

I currently us the OS parental controls, but that is only good for the computer it is enabled on.

I understand that as my kids grow up, they'll figure out work arounds to any technical parental restrictions imposed upon them, but I want to at least understand the options that I have until then.

share|improve this question
I've done this for sending reminders to my phone - I'll post the recipe when I can ssh to my server :) – warren Sep 14 '09 at 12:33
added the whitelist recipe as promised :) – warren Sep 16 '09 at 12:59
Nice stuff. I'll have to try this out as well. – pave Sep 16 '09 at 13:07
up vote 1 down vote accepted

procmail can filter by the From header, and there are many recipe examples.

# This one discards all mail sent from the address below.
* ^From:

But don't forget that procmail only works with locally delivered mail. It won't affect mailboxes accessed over IMAP or webmail.

share|improve this answer
This is a blacklist recipe. Do you know how to do it the opposite? Such as only allow mail from certain addresses. – hanleyp Sep 5 '09 at 16:59
Just change the recipe to use ${DEFAULT} as the mailbox, then add a second recipe that routes the rest to /dev/null. – grawity Sep 6 '09 at 8:07
Thanks. I'll accept the answer once I have a chance to try it out. – hanleyp Sep 9 '09 at 13:32
@RoninTom's answer is simpler and more to the point. – tripleee May 17 '13 at 8:10

The one I use to send messages from myself to my phone:


# if it comes from a specific address(es), send to my cell
# it's be just as easy to whitelist a domain by adding another `|domain.tld` section to the bracketed regex
* ^From.*[|]
* ^To.*datente

# push everything else to my normal user
* .
! mainuser
share|improve this answer
also note: I intentionally only gather email sent to the one domain, not any others hosted on the same server – warren Sep 18 '09 at 5:23

I think we have not any solution yet, that exactly solves the initial problem. Therefore, I would like to provide a more explicit approach. Lets suppose, that our whitelist looks like this:


Then I would try the following reciept:

* !^From.*@white\.domain\.tld
* !^From.*@light\.domain\.tld

This would send all emails that are not from somebody@white.domain.tld and not from somebody@light.domain.tld to /dev/null. The remaining emails are send to the default destination. Be aware to use \. in your pattern if you like to match a single dot. The pattern . matches a single character.

If you have a short whitelist, you could try to get an even shorter reciept by combining the patterns:

* !^From.*@(white|light)\.domain\.tld

Be aware to use ( ) here. Using [ ] would be a mistake.

share|improve this answer

I'm not at all sure where I got this from (I know I didn't write it myself), but I've been using it in a .procmailrc for a while now to forward only messages from an address listed in a separate whitelist file to a given target email address:

PMDIR=$HOME/Procmail      # Make sure this directory exists!

# allow any addresses listed in $PMDIR/whitelist
FROM_ADDR=`formail -zxFrom: | sed 's/\(.*[^-_\.0-9a-zA-Z]\)\?\([-_\.0-9a-zA-Z]\+@[-_\.0-9a-zA-Z]\+\).*/\2/'`
* ? fgrep -xs "$FROM_ADDR" "$WHITELIST"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .