Sunday, 31 July 2011

Email for Kids - and moderating messages

I want to give my two kids (5 & 7) email. If I don't, eventually they'll sort themselves out on gmail or something and whilst gmail might do a good job of getting rid of willy pill spams, it won't protect your kids against approaches by undesireables or bullying.

So, this assumes you run your own email server (or can):

The basic requirements are:
  • Anyone can email them, but all such emails are trapped in a queue
  • A moderator (ie one or more of the child's guardians) will be alerted  when there are new emails waiting and can approve or reject each one after checking the content.
  • Some sender addressed could be whitelisted - ie will bypass the requirement for moderation. Do this for your own email addresses or for the kid's trusted friends.
Sounds  a bit like a mailing list doesn't it? A lot like it in fact. Well, to be specific: a mailing list with one member (the kid's physical mailbox address), posting allowed by non list members with the default policy of "hold for moderation".

Mailman meets the requirements here, so this is a quick howto, assuming the mail system itself is exim (using other systems should be possible.

The only other problem is that we should block the kid's physical mailbox address from being able to receive external mail, though it must be able to receive mail from mailman.

Exim config snippets

In the ACLs section, you can put in the bit that disallows external hosts from being able to send directly to the kid's local mailbox:


deny    local_parts = ^.*[@%!/|] : ^\\.

deny hosts = !+relay_from_hosts  
  condition = ${if exists{/etc/exim4/domains/$domain/uservialist}}
  condition = ${lookup{${sg{$local_part}{\N[_\+].+$\N}{}}}lsearch{/etc/exim4/domains/$domain/uservialist}{true}{false}}
  logwrite = Recipient address $local_part@$domain blocked by \
  user protection list /etc/exim4/domains/$domain/uservialist
  message = Recipient globally blocked (handled by list)
accept  hosts           = :

The bit you want is the red part, somewhere near the top of the acl_smtp_rcpt ACL. My setup is multidomain, but if yours is a single domain setup, you could simplify the condition and logwrite lines to:

/etc/exim4/domains/$domain/uservialist -> /etc/exim4/uservialist

This file contains a list of local usernames of your kids, one per line.

Note the sg{} rexeg - this is because I run a system with throwaway email addresses (ie for any valid local part "local", "local+<anything>" and "local_<anything>" are valid addresses mapping back to "local").

If you don't do this, you could simplify that line to:

condition = ${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/uservialist}{true}{false}}

Routers section:

Standard mailman config (file locations correct for Debian 6, may need to adjust for other OSes):

        debug_print = "R: mailman_router for $local_part@$domain"
        domains = +local_domains
        require_files = MAILMAN_HOME/lists/$local_part/config.pck
        driver = accept
        local_part_suffix = -bounces : -bounces+* : \
                      -confirm+* : -join : -leave : \
                      -subscribe : -unsubscribe : \
                      -owner : -request : -admin : -loop
        transport = mailman_transport
        group = MAILMAN_GROUP 

You will need the following definition in the global section of the exim config list:



The only thing left is to configure the mailman list. You'll need to configure the web interface to mailman but the supplied apache.conf snippet in the debian package is OK.

Assuming your kid has a username of kiduser, your domain is and you want them to have an email address of :

Create a list called "kid". Subscribe "" to this list (the only member).
Set yourself and any other guardians' email addresses as the list moderator. 

You may turn off the List-* headers and remove both the subject line prefix [kid] and the standard signature that usually gets added to list emails.

"What steps are required for subscription?" should be set to "Require approval"
"Action to take for postings from non-members for which no explicit action is defined." MUST be set to "Hold" - This is the route by all of the emails come in.

Whitelisting friends:

Add trusted sender addresses to the section: "List of non-member addresses whose postings should be automatically accepted." Do not make such people list members or everyone gets a copy of all emails!!
The beauty is that you can moderate either using the web interface or by email. Mailman will email the list moderators every time a non approved sender emails your kid. Any of the list moderators can approve or reject any of the emails and can choose, on the web interface, to whitelist the sender.

Of course, if you want to monitor your kid's emails, even whitelisted ones, you could add yourself as a list member and you will get a copy of everything.

No comments:

Post a Comment