Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

My home network is set up as follows:

PCs -> Wired Network    ---|
                           |--- Server --- Internet
PCs -> Wireless Network ---|

The server runs the fetchmail, postfix and dovecot daemons under Ubuntu to retrive e-mail from the ISP and store it on the server. E-mail is accessed from any of the PCs on the wired or wireless networks via an IMAP interface hosted on the server.

This all works great.

I'm about to let my young children use e-mail for themselves. But before I let them loose on the world, I wanted the server to implement a whitelist for e-mails that are retrieved from the ISP and sent to their mailbox. Ideally, the incoming senders full address should be listed in the whitelist for it to be forwarded to the mailbox. Anything that isn't in the whiltelist should be forwarded to a different mailbox which I can then look through and update the whitelist as appropriate.

How do I set up the various daemons to do this?

share|improve this question
up vote 1 down vote accepted

I think sieve can manage what you want achieve.

To get a fully setup mailsystem + sieve + webmail i can recommend iRedMail (

Sieve supports the moving and filtering of mails.

share|improve this answer
Well, there appears to be a Dovecot plugin to parse sieve scripts that should do exactly what I want, but I just need to figure out how to install the sieve plugin. – Skizz Sep 16 '10 at 23:32
Update: Installed the dovecot-dev package then the sieve package from the dovecot website. Seems to have worked without any problems. – Skizz Sep 16 '10 at 23:46

I've accepted aatdark's answer, but here's a more detailed description of what I did (I haven't the rep to edit aatdark's post).

First off, I'm using Ubuntu 9.04.

Also, there was no need to install additional packages.

I had a set up like this:

ISP -> fetchmail -> postfix -> dovecot (for imap access)

I needed postfix to use dovecot's deliver program as that had the ability to run sieve scripts. To do this, edit the in /etc/postfix and change or add the following:

mailbox_deliver = /usr/lib/dovecot/deliver

This tells postfix to use dovecot's deliver program. To get deliver to run sieve scripts, edit dovecot.conf in /etc/dovecot and find the line with

protocol lda {

and add the following entries:

postmaster_address = <some address>
hostname = <hostname>
mail_plugins = cmusieve
sendmail_path = /usr/lib/sendmail

Finally, to implement the whitelist as I originally required, search the dovecot.conf for

plugin {

add the following:

sieve = <location of sieve script> # I have /var/sieve-scripts/%n.sieve, this uses the user name as part of the script filename

and the script file looks like:

if address :is ["From"] "whitelisteduser@domain"
    keep; # we know this user so let it through
    redirect "myemail@domain"; # redirect everything else

It's a simple script, I know. But it's a start. I hope there's a way to use an external data source instead of the explicit sender's email address

share|improve this answer

You need to use some filtering middleware like amavisd. But setting it up is quite complicated, there is a how-to set it up, integrate it in postfix, spamassasin (antispam) and clamd (antivirus) in the community documentation.

Setting is white-list in amavis is quite easy if you manage to get that far. Just look at the /etc/amavis/conf.d/20-debian rules.

share|improve this answer
i think he wants to deliver the flagged mails into a different email account. I think he don't want to treat the mails as spam. (if you have to setup the whole amavis stuff you should take a look at iRedMail ) – aatdark Sep 15 '10 at 16:49
You can do that with amavis. But it's quite complex :(. – Javier Rivera Sep 15 '10 at 17:31
Yes, I do want to send the flagged e-mails to a different account and sieve seems to provide this. I think it's installed and running and I'm just setting up some tests now to try it out. – Skizz Sep 17 '10 at 8:41

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.