Home IMAP server

Todd Slater dontodd at gmail.com
Fri Dec 29 13:58:39 UTC 2006


Hi Dotan,

On 12/29/06, Dotan Cohen <dotancohen at gmail.com> wrote:
> On 28/12/06, Todd Slater <dontodd at gmail.com> wrote:
> > > 5) If I continue using bogofilter in Kmail, it will only filter the
> > > mail on that machine. Or, is there a way to have bogofilter in the
> > > IMAP server itself? That way it will learn from when I tag ham/spam on
> > > both machines.
> >
> > Yes, you'd want bogofilter to run on the same machine as your IMAP
> > server so that no matter what machine you access your mail from, mail
> > gets passed through bogofilter. I've got a server set up like this,
> > and the process is that postfix receives the mail and hands it off to
> > procmail, which sends it through bogofilter and then delivers it to
> > the local mailboxes. All training can be done via the mail client, by
> > dragging and dropping messages to the appropriate folder.
> >
> > I set up bogofilter and folders like this:
> >
> > a .Junk folder, where mail identified as spam goes.
> >
> > a .MakeJunk folder, where misclassified ham goes (bogofilter thinks
> > it's ham but it's really spam)
> >
> > a .MakeGood folder, where misclassified spam goes (bogofilter thinks
> > it's spam but it's really ham)
> >
> > Since bogofilter uses tristate classification now, I have approached
> > the unsure messages in one of two ways, either
> >
> > 1. having bogofilter put ???UNSURE??? in the subject line so I'll know
> > it's unsure, or
> >
> > 2. creating an .Unsure folder where procmail can put those messages.
> >
> > I then run scripts via cron on the server that process mail in
> > .MakeJunk, .MakeGood, and .Unsure. These basically run every couple of
> > hours and run the mails through bogofilter with the appropriate
> > switches for training. I only keep one week worth of spam in my Junk
> > folder, anything older than 7 days gets moved out of my maildir and to
> > another folder outside of my mail root. I tar.gz that directory every
> > week or so to save space.
> >
> > Since the vast majority of my unsures are actually spam, I have a
> > script that automatically classifies those mails older than 7 days as
> > junk and move them to my spam archive.
> >
> > Let me know if you need details on my server setup, it's on Ubuntu, too.
> >
> > Todd
> >
>
> Todd, that looks like the perfect setup, and that's exactly what I'm
> going to do. Could you please tell me exactly what programs you are
> using, so that I can start googling. I see postfix, procmail,
> bogofilter, and cron. What IMAP server aer you using?

Yes, postfix, procmail, bogofilter, and dovecot for IMAP. I also use
RoundCube for web access. You would be using fetchmail too, as I
understand.

> ALso, please tell me if I'm understanding this correctly. Postfix
> connects to a remote POP3 machine and pulls the mail down.

In my case, it's just a regular mail server so postfix is listening
for mail connections and receives mail for my domains. But yes, you'd
use fetchmail to pull mail from other servers. I have used fetchmail
in this system as well, and it just works as it passes mail to
postfix, thus starting the whole process.

It then
> passes the mail to procmail, which runs bogofilter and based on
> bogofilter's response, procmail puts the mail in the appropriate
> folder. The IMAP server then has access to it, and can serve email to
> your client (Tbird, Kmail, etc.).

Exactly.

Now, when you get a spam in ham, or
> vice versa, you put it in a special spam->ham or ham->spam folder so
> that bogofilter can learn from it. Every so often, cron comes along,
> parses those special folders, and send the email to bogofilter so he
> can learn. Is that what's happening?

Yes.

> Thank you very much for your assistance.

There's not much tricky about this setup, but I always run into
trouble with postfix/procmail. The only required change to the postfix
configuration as far as I can tell is to put this in
/etc/postfix/main.cf:

mailbox_command = /usr/bin/procmail -Y -a $DOMAIN

In my .procmailrc, I have my bogofilter rules:

:0fw
|bogofilter -u -e -p

:0e
{ EXITCODE=75 HOST }

:0
* ^X-Bogosity: Unsure, tests=bogofilter
.Unsure/

:0
* ^X-Bogosity: Spam, tests=bogofilter
.Junk/

I happen to register every mail with the db, thus the -u switch. I
think that once you get your server set up, you won't want to use any
client-side filtering at all; it's so much easier to set it up one
time in your procmail rc files.

Let me know if you want to see the cron scripts.

Todd




More information about the ubuntu-users mailing list