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.

hanleyp
  • 6,625

4 Answers4

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!
TARGET=something@example.com

# 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
Isaac
  • 192
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: idiot@somehost.com
/dev/null

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

grawity
  • 501,077
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
! 0000000000@vtext.com

# push everything else to my normal user
:0 
* .
! mainuser
warren
  • 10,322
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 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:

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

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

Ronin Tom
  • 111