[Dovecot] Question: email system architecture
Hi,
I have a question about how to implement a mail system, but I don't know where to ask.
Until now, I have a mail system who receive mail by postfix and transport it through procmail to the /var/spool/mail/username mailbox. From here it is retrieved through dovecot (POP3).
Now I have two more users, I want to implement a IMAP server, and also provide a webmail (squirrelmail) interface. And in order to filter spam, I want to install spamassassin. Until now it was thunderbird who made the filterring, but with a webmail interface it's no more possible.
So suppose that I have configured procmail to deliver "good" mail in an Inbox folder and "spam" in a SPAM folder. This for each user mailbox. I also have configured dovecot as IMAP server and any IMAP client can see the two folder with spam and ham.
And here comes my implementation problem. If a user see a "good" mail in his spam folder (or vice-versa) he will take this mail and move to his inbox folder. But, I want to be able to say to spamassassin to learn that this message is ham, with the command sa-learn, and also remove the x-spam* headers. And I don't see a good way to do that.
In my opinion, it should be the MUA task, but spamassassin is server based. It's any way that dovecot when it moves the mail between tho folders can call an external script who will make this job in fonction of source/destination folder?
Maybe it's a silly question (I don't know IMAP and his possibilities). In this case, can anyone explain (or point to) me a way to do that ?
Sorry for this long message.
Edd.
On Tue, 17 Aug 2004 20:20:31 +0200 Gland Vador glandvador@yahoo.com wrote:
If a user see a "good" mail in his spam folder (or vice-versa) he will take this mail and move to his inbox folder. But, I want to be able to say to spamassassin to learn that this message is ham, with the command sa-learn
Run a daily (or nightly) cron job to run something like (this is for Maildir mailboxes with spam in a "_SPAM" folder, but you can adapt it as required):
------------------cut here------------------- #!/bin/bash find /home -type d -name cur | while read a; do echo "Processing $a..." if [ echo $a|grep _SPAM/cur ]; then sa-learn --spam "$a" else sa-learn --ham "$a" fi done
--
Small business computer support: http://www.tiger-computing.co.uk
Linux consultancy: http://www.TheLinuxConsultancy.co.uk
On Tue, 17 Aug 2004 23:40:53 +0100 Keith Edmunds keith@midnighthax.com wrote:
On Tue, 17 Aug 2004 20:20:31 +0200 Gland Vador glandvador@yahoo.com wrote:
If a user see a "good" mail in his spam folder (or vice-versa) he will take this mail and move to his inbox folder. But, I want to be able to say to spamassassin to learn that this message is ham, with the command sa-learn
Run a daily (or nightly) cron job to run something like (this is for Maildir mailboxes with spam in a "_SPAM" folder, but you can adapt it as required):
------------------cut here------------------- #!/bin/bash find /home -type d -name cur | while read a; do echo "Processing $a..." if [ echo $a|grep _SPAM/cur ]; then sa-learn --spam "$a" else sa-learn --ham "$a" fi done
why #!/bin/bash?
I see nothing there that won't work with #!/bin/sh
bash bad, think POSIX not Linux
--andrew
On Tue, 17 Aug 2004 23:40:53 +0100, Keith Edmunds keith@midnighthax.com wrote:
Run a daily (or nightly) cron job to run something like (this is for Maildir mailboxes with spam in a "_SPAM" folder, but you can adapt it as required):
Might want to add a delay on that or only match messages that have been Seen, otherwise it'll classify mail that hasn't been read yet. Maybe..
find /home/*/Maildir/*/ -type d -name cur | while read cur; do
foldername=dirname "$cur"
find "$cur" -type f -name '*,*S*' | while read file; do
if [ x"$foldername" = x"_SPAM" ]; then
sa-learn --spam "$file"
else
sa-learn --ham "$file"
fi
done
done
On second thought, you probably don't want to feed sa-learn every message, every day - just the new ones, right? ..
Zach.
On Wed, 18 Aug 2004 17:47:36 +1200 Zach Bagnall zach.bagnall@bulletinwireless.com wrote:
Might want to add a delay on that or only match messages that have been Seen, otherwise it'll classify mail that hasn't been read yet. Maybe..
That is not a problem - if something is wrongly classified but then later moved, the next sa-learn will correct the Bayes database.
On Wed, 18 Aug 2004 01:16:00 +0100 Andrew Basterfield bob@cemetery.homeunix.org wrote:
why #!/bin/bash?
I see nothing there that won't work with #!/bin/sh
That's probably true, but I see no reason to specify sh just because it will work. If you feel bash is the wrong way of going about this, feel free to change it! The original poster was asking how to solve a particular problem, and as it was one that I had solved myself I decided to help him out. I do not for one moment pretend that mine is either the perfect or only answer, but it does have one redeeming feature: it works.
Keith
Keith Edmunds wrote:
If a user see a "good" mail in his spam folder (or vice-versa) he will take this mail and move to his inbox folder. But, I want to be able to say to spamassassin to learn that this message is ham, with the command sa-learn
Run a daily (or nightly) cron job to run something like (this is for Maildir mailboxes with spam in a "_SPAM" folder, but you can adapt it as required):
snip script
This is an idea. But what to do if a user (like me) will empty his spam folder once he looked inside to verify that there is no ham ? It's a lot easier to deal with a tiny spam box.
In my case, I receive about 1/150 ham/msgs so if I want spams to (re)learn the bayesian filter I just wait 1 week. For the good messages I have all my mails. So I dont keep spam.
On the other side, this will work for ham. Because, in theory, it will stay longer in the system. But again, I dont know how to remove the x-spam* headers from the mail.
Edd.
participants (4)
-
Andrew Basterfield
-
Gland Vador
-
Keith Edmunds
-
Zach Bagnall