2

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.

3
  • 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, 2009 at 12:33
  • added the whitelist recipe as promised :)
    – warren
    Sep 16, 2009 at 12:59
  • Nice stuff. I'll have to try this out as well.
    – pave
    Sep 16, 2009 at 13:07

4 Answers 4

1

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

# This one discards all mail sent from the address below.
:0
* ^From: [email protected]
/dev/null

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

3
  • 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, 2009 at 16:59
  • 1
    Just change the recipe to use ${DEFAULT} as the mailbox, then add a second recipe that routes the rest to /dev/null. Sep 6, 2009 at 8:07
  • @RoninTom's answer is simpler and more to the point.
    – tripleee
    May 17, 2013 at 8:10
1

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

VERBOSE=off
LOGFILE=/dev/null

# 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
:0
* ^From.*[main.email.domain.tld|other.email.domain.tld]
* ^To.*datente
! [email protected]

# push everything else to my normal user
:0 
* .
! mainuser
1
  • also note: I intentionally only gather email sent to the one domain, not any others hosted on the same server
    – warren
    Sep 18, 2009 at 5:23
1

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:

white.domain.tld
light.domain.tld

Then I would try the following reciept:

:0
* !^From.*@white\.domain\.tld
* !^From.*@light\.domain\.tld
/dev/null

This would send all emails that are not from [email protected] and not from [email protected] 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:

:0
* !^From.*@(white|light)\.domain\.tld
/dev/null

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

1

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!
[email protected]

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

You must log in to answer this question.

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