Full Installation Guide - Maildrop

From Qmail-LDAP Wiki

Jump to: navigation, search

Up

Contents

Introduction

You can mark all the spam (or most of it) with SpamAssassin. But what if you want to let it pass and store it automatically in a special IMAP folder (just like Yahoo or Gmail)? You can do it with maildrop, a program to filter messages in a way very similar to procmail. With maildrop you can do things like, for example, send incoming mail from your girlfriend and from all the mailing list you are subscribed to different IMAP folders. The following section describes how to do this.

Installation

The logic is this:

  1. Make every incoming mail be processed by maildrop.
  2. Configure maildrop to recognize incoming mail marked by spamassassin and send it to Spam IMAP folder.

Enabling maildrop for qmail and users

To enable maildrop, we must setup the appropiate control files so that an external program can be used and then set the correct attributes for every user with this feature. To activate third party programs globally in qmail, do the following:

echo ldapwithprog>/var/qmail/control/ldapdefaultdotmode

And set the next content in the deliveryProgramPath attribute for every user which will use maildrop:

/usr/local/bin/maildrop 

To avoid duplicate mails, set deliveryMode attribute to:

nolocal

Configure maildrop

Now lets create a default configuration file for maildrop. This is done in /usr/local/etc/maildroprc(FreeBSD) or /etc/maildroprc(Debian):

import HOME
import MAILDIRQUOTA

XBOUNCE="| bouncesaying 'Sorry, no mailbox here by that name.'"

if (/^X-Spam-Status: Yes/)
{
        to "$HOME/Maildir/.Spam/"
}
if ( $HOME eq "" )
{
        to "$XBOUNCE"
}
else
{
        exception {
                include "$HOME/.mailfilter"
        }
        exception {
                to "$HOME/Maildir"
        }
}
to "$HOME/Maildir"

With this all mails with header X-Spam-Status: Yes (marked by SpamAssassin) will be sent to an IMAP folder called Spam. This will also check if there exist a ~/.mailfilter for every user, and if if finds it, load the file and so set a different behavor for current user. For example, if I create a ~/.mailfilter(/var/vmail/oarmas/.mailfilter) like this:

if (/@spamassassin.apache.org/)
{
        to "$HOME/Maildir/.SPAMASSASSIN/"
}

if (/^From:.*girl@mygirlfriend.com/)
{
        to "$HOME/Maildir/.GIRLFRIEND/"
}

to "$HOME/Maildir/.MAIN/"
#to "$HOME/Maildir", to send the rest to INBOX


will make that any mail from @spamassassin.apache.org be sent to folder SPAMASSASSIN(which must be created before), and all mail from girl@mygirlfriend.com be sent to GIRLFRIEND. All the rest of the mail will be sent to MAIN folder. If you want to send it to INBOX, use commented line instead.

Personal tools