Introduction
============
Normally spamd looks for user_prefs for users listed in /etc/passwd. Of course
with vpopmail this doesn't work since vpopmail are virtual users and do not 
exist in /etc/passwd. But each vpopmail user does have their own maildir where
personal user_prefs can be stored.  I have patched spamd to look for user prefs
in the users vpopmail maildir. 

Requirements
============
1. This should work with v.5.0.1-5.20 of vpopmail as long as it has the 
seekable patch installed to allow you to use filters like procmail or 
maildrop in the .qmail-default file.  See http://www.thesafebox.com for this 
patch.  Older versions may work w/o patch but I don't know for sure.
2. SA v.2.20
3. Procmail or maildrop for filtering and running spamc.


Usage Tips and Examples
=======================
1. Run spamc with the "-u userid@somedomain.net" option. This is how spamd 
determines what the vpopmail users name is and therefore their maildir.
2. Run spamd with the following switches: 

	spamd -v -u vpopmail (of course any other ones that you use) 

where "vpopmail" is the name of your vpopmail account in /etc/passwd. 
spamd will now run with proper ownership and will be able to read/write to any
vpopmail maildir. I would suggest you consider running spamd as:

	spamd -d -v -u vpopmail -F 0 

3. You can also use -c switch so that it will auto-create user_prefs file or 
use some other interface outside of SA to create the personal user_prefs 
(perhaps a modified phpsa interface).  User_prefs dir will be created in the 
vpopmail users maildir. It gets this info from the command:
        vuserinfo -d userid@somedomain.net

For example if the user's maildir is:
	/home/vpopmail/domains/somedomain.net/4/userid

then their user_prefs would be stored in:
	/home/vpopmail/domains/somedomain.net/4/userid/.spamassassin/user_prefs

5. One gotcha - cannot have personal AWL dbs - only a sitewide AWL will work. 
This is specified in your /etc/mail/spamassassin/local.cf file. Then add the 
"-a" switch to spamd. Perhaps a future enhancement would be to add the 
capability to have personal AWL db. 

6. Of course vpopmail must have the seekable patch installed (see 
http://www.thesafebox.com for patch). This will allow you to use procmail or 
maildrop for filtering in the global .qmail-default file for each virtual 
domain that you host.

7. Dallas Engelken contributed the following example files using maildrop:
after you have the seekable patch applied, you can filter through maildrop
by changing your domain/.qmail-default file to
| preline maildrop mailfilter

the mailfilter file must be owned by vpopmail:vckpw and have 0600
permissions.  otherwise maildrop will not process it.  the contents of
mailfilter should be something like this (of course edit paths to match your 
setup):

####################################################
VPOP="| /var/vpopmail/pop/bin/vdelivermail '' bounce-no-mailbox"
VHOME=`/var/vpopmail/pop/bin/vuserinfo -d $EXT@$HOST`

if ( $SIZE < 262144 )
{
        exception {
                xfilter "/usr/bin/spamc -f -u $EXT@$HOST"
        }
}

if (/^X-Spam-Flag: *YES/)
{
        exception {
                include $VHOME/Maildir/.mailfilter
        }
## IF YOU WANT TO GATHER ALL SPAM INTO 1 MAILDRIR
        #exception {
        #        to /home/pop/spam/
        #}
## OR IF YOU WANT TO DELIVER SPAM TO THE USERS MAILDIR
        exception {
                to "$VPOP"
        }
}
else
{
        exception {
                include $VHOME/Maildir/.mailfilter
        }
        exception {
                to "$VPOP"
        }
}
####################################################


8. Of course there are a myriad of ways to deliver the mail.  For instance at 
my site I divert all Spam to each individuals own Spam IMAP folder so I would 
use:

   to $VHOME/Maildir/.Spam

(of course .Spam must have been created ahead of time using maildirmake 
command).


Hope this helps,
Ed Henderson <ed.henderson@certainty.net>

