[Dovecot] Spam filtering

Patrick Nagel patrick.nagel at star-group.net
Tue Dec 15 08:20:23 EET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Dmitri,

On 2009-12-15 04:54, Dmitri V. Ivanov wrote:
> On Mon, Dec 14, 2009 at 09:30:54PM +0100, Marcus Rueckert wrote:
>>> Is there a way do something like that with deliver?
>> 
>> why not do it on MTA level? those already have the hooks for it 
>> normally. no need to reinvent the wheel imho.
>> 
> 
> Sometimes it's virtual users using dovecot userdb or something like.
> MTA isn't aware of it (all it uses for virtual user is mailbox
> presence). But each virtual user have own wordlist for bogofilter.
> deliver would set some environment variables like $HOME to desirable
> values for such virtual user and then we have good place to call
> filter pointing it to virtual user home directory.

Indeed, that would be more straight-forward than what's currently needed
(from an administrator's point of view, at least).

We have postfix configured to pipe to-be-delivered mails into a shell
script that takes ${recipient} (the recipient's e-mail address) as first
argument (here is the relevant part from master.cf):

spamcheck       unix    -       n       n       -       -       pipe
    flags=DRhu user=maildeliver:maildeliver
    argv=/usr/local/libexec/spamcheck_and_deliver ${recipient}

The script then pipes the mail through `/usr/bin/spamc -u 'left part of
e-mail address'` (which lets spamassassin's spamd do the checking and
insertion of headers, and thanks to the -u parameter for each user a
separate bayes_journal, bayes_seen and bayes_toks file is being used).

That output then gets finally piped into `deliver -d 'e-mail address'`,
which files the mails into the inbox/spam/unsure mailbox, according to a
global sieve script that checks the headers previously inserted by spamd.

My private bogofilter setup is simpler, since it's just for me, but you
could do it similarly, by specifying the user's bogofilter wordlist
directory (-d ...) in the shell script (I think).

Patrick.

- -- 
STAR Software (Shanghai) Co., Ltd.            http://www.star-group.net/
Phone:    +86 (21) 3462 7688 x 826             Fax:   +86 (21) 3462 7779

PGP key E883A005 https://stshacom1.star-china.net/keys/patrick_nagel.asc
Fingerprint:           E09A D65E 855F B334 E5C3 5386 EF23 20FC E883 A005
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/

iEYEARECAAYFAksnKqUACgkQ7yMg/OiDoAXP3QCfekl4XpYu3Za2Zxt/JVbgVOMl
ZcQAn0jtmQLBqhltpuJl+jcktPx+bO6O
=ejbL
-----END PGP SIGNATURE-----


More information about the dovecot mailing list