View Full Version : shared imap folders
hal9000
02-20-2007, 11:33 AM
this is not actually related to qmail but to courier-imap, but maybe someone can give me a hint anyway.
I want to set up a virtual shared imap folder where any user can put spam messages not recognized by spamassassin, in order to use them for sa-learn. I followed the howto found on http://www.courier-mta.org/imap/?README.sharedfolders.html:
- added the following line to /usr/lib/courier-imap/etc/shared.tmp/index:
[tab]spamuser@domain.com[tab]0[tab]0[tab]/home/vpopmail/domains/domain.com/spamuser[tab]
- installed the file with /usr/lib/courier-imap/sbin/sharedindexinstall
- set up the acl for spamuser@domain.com with /usr/lib/courier-imap/bin/maildiracl (anyone aceilrstwx)
just to be sure, I even restarted courier-imapd. it doesn't barf at anything (no errors or warnings of any kind are logged), but the shared folders do not show up in the mail client (using thunderbird). what am I missing???
thanks,
- Dave.
roreilly
03-09-2007, 05:57 PM
Here's the approach I took, hopefully it helps you.
Created new users for spam, with no login permissions and made that user world-writable.
I wrote a script that symlinks $user/Maildir/.SPAM to the spam account.
Everyone can subscribe to it via imap, and then drag & drop any spam into that folder.
a crontab entry that runs sa-learn against the spam user inbox runs every hour up@#$%!@#$%!@#$%!@#$%!@#$%!@#$%! the system.
Hope that is useful.
R.
KingKingAli
09-05-2007, 06:28 AM
That is a very clever approach, I wish I have thought of it...
That being said...
I am about to migrate to a new server, and on this server I have chosen the approach of training SpamAssassin in a user specific way to allow for more accurate SpamFiltering for the individual person. Yes I know what is spam for you is spam for me, but why run checks for spam that you don't get.
I installed SquirrelMail with SpamAssassin SQL, this is mostly to have an automated way of creating .Learn_Spam and .Learn_Ham folders then since I couldn't get the perl script that came with SA Sql to work, I write my own shell script that parses the /home/vpopmail/domains directory, then for each domain (domain identified by being a directory) and each use in the domain (user being a folder again) I construct their email address, and run SA on their Learn_Spam and Learn_Ham folders...
Then I set this script in my Crontab to execute every Sunday...
Advantage is, even if you dont want to make it user specific, it saves you the hassel, of the linking stuff and manually having to run SpamAssassin.
My script is pasted in case someone needs something similar:
#!/bin/bash
#
# Script by Ali Muzaffar, automatically trains
# SpamAssasin using the specified folders, username is also extracted
# and SpamAssassin is then trained for the specific user.
#
# Set the field seperator to a newline
IFS="
"
VPOPDIR=/home/vpopmail/domains
MAILDIR=Maildir
SPAM=$MAILDIR/.Learn_Spam
HAM=$MAILDIR/.Learn_Ham
LOGFILE=/var/log/sa-autolearn.log
echo === START === > $LOGFILE
# list all files in the directory, the ls -F command lists all directories with / in them
# remove the / with the cut command
#for DM in `ls -F $VPOPDIR/ | cut -f 1 -d /`;do
for DM in `ls $VPOPDIR`;do
echo "Domain = $DM" >> $LOGFILE
# list all directories, remove the / at the end of them
# (the cut command remove the / character).
#for UZR in `ls -F $VPOPDIR/$DM/ | cut -f 1 -d /`;do
for UZR in `ls $VPOPDIR/$DM`;do
CURDIR=$VPOPDIR/$DM/$UZR
# Check if directory exists (this has the benefit of
# eliminating files from the list and leaving only directories
# these directories will be domain names so in effect the loop is
# for each directory / domain (make sure there are no other directories
# other than virtual domain directories
#if [ "`ls -a $CURDIR`" != "$CURDIR" ] # really crappy way to do this.. ignore it
if [ -d $CURDIR ]
then
#echo $CURDIR
#echo $UZR@$DM
#echo $CURDIR/$SPAM
#
# Make sure we only pick up directories, also since our spam directory is called
# .Learn Spam, we need sed so remove the \ for the check to work.
# We check if the Learn Spam directory exists, if it doesn't, we skip the user. If there are spaces in your path, use the sed version of the command
#if [ -d `echo $CURDIR/$SPAM | sed -e 's/\\\//g'` ]
if [ -d $CURDIR/$SPAM ] #use this is there is no space in the folder names
then
echo "Processing Spam for $UZR@$DM" >> $LOGFILE
/usr/local/bin/sa-learn --spam --username=$UZR@$DM $CURDIR/$SPAM 1>>$LOGFILE 2>>$LOGFILE
echo "Processing Ham for $UZR@$DM" >> $LOGFILE
/usr/local/bin/sa-learn --ham --username=$UZR@$DM $CURDIR/$HAM 1>>$LOGFILE 2>>$LOGFILE
#Delete everything in the Learn Spam folder
rm -f -v $CURDIR/$SPAM/cur/* $CURDIR/$SPAM/new/* 1>>$LOGFILE 2>>$LOGFILE
#move emails in Learn Ham to INBOX
mv $CURDIR/$HAM/cur/* $CURDIR/$MAILDIR/cur/ 1>>$LOGFILE 2>>$LOGFILE
mv $CURDIR/$HAM/new/* $CURDIR/$MAILDIR/cur/ 1>>$LOGFILE 2>>$LOGFILE
# echo $CURDIR/$SPAM Directory Found
#else
# echo $CURDIR/$SPAM Directory does not exist
fi
fi
done
done
exit 0
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.