Just answering my own email. I made a stunning/stupid discovery. The maildrop filters out there that do the directory assignment like this:
VHOME=`/home/vpopmail/bin/vuserinfo -d [EMAIL PROTECTED] are inherently broken for catchalls. This may be obvious to some, but I was blindly trusting stuff I found on the mailing list, which can be dangerous. If for example I have a user "spork" as the catchall for "fasttrackmonkey.com" and mail is sent to "[EMAIL PROTECTED]" current versions of vdelivermail will read spork's .qmail file which in turn calls maildrop with a filter using the above construct. Well, there is no such user as "[EMAIL PROTECTED]", so $VHOME is empty. That in turn leads to bad things. The other example I've seen relies on a variable called "PWD". For whatever reason, my maildrop can *never* see that variable (tested under vpopmail 5.3.21 - .24). Whether that's some quirk in my version of maildrop (1.5.2) or something else that I'm not seeing, that solution doesn't work for me. However, I like the idea in theory. So, here's what I've come up with to handle filtering on normal users and catchall users. Running it right now on 5.3.24. Qmailadmin is set to put "|preline /usr/local/bin/maildrop /usr/local/etc/mailfilter.user" in a user's .qmail file if they click the "enable spam detection" button. The filter calls spamc, looks for a "Spam" folder in the user's Maildir, creates one if it doesn't exist, then delivers spam to that folder. Additionally it looks for a ".mailfilter" file in the user's Maildir and reads that if it exists. Here's the contents of /usr/local/etc/mailfilter.user: ---- SHELL="/bin/sh" VDIR=`pwd` # grab PWD by running the pwd command USERNAME=`echo ${VDIR##*/}` USERHOST=`PWDTMP=${VDIR%/*}; echo ${PWDTMP##*/}` logfile "/home/vpopmail/domains/fasttrackmonkey.com/maildrop.log" #testing log "===== BEGIN" log "=== VARS: host - $USERHOST name - $USERNAME vdir - $VDIR" if ( $SIZE < 262144 ) # don't kill spamd with huge messages { exception { xfilter "/usr/local/bin/spamc -f -u [EMAIL PROTECTED]" log "=== SPAMC called" } } if (/^X-Spam-Flag: *YES/) # Did spamc call it spam? { # try filtering it using user-defined rules log "== SPAM YES" exception { log "= PARSING $VDIR/Maildir/.mailfilter" include $VDIR/Maildir/.mailfilter } log "== SPAM YES back from included file" # make sure .Spam folder exists `test -d ./Maildir/.Spam` if( $RETURNCODE == 1 ) { log "= CREATING SPAMDIR" `maildirmake -f Spam ./Maildir` } # then try delivering it to a Spam folder exception { log "= DELIVERING SPAM to $VDIR/Maildir/.Spam/" to "$VDIR/Maildir/.Spam/" } exception { log "== SPAM YES - couldn't deliver to .Spam folder" to "$VDIR/Maildir" } } else { log "=== SPAM NO" exception { log "== PARSING $VDIR/Maildir/.mailfilter" include $VDIR/Maildir/.mailfilter } log "== BACK FROM INCLUDE" exception { log "= DUMP to Maildir" to "$VDIR/Maildir" } log "==== EXITING" } ---- And here's a snippet of an included .mailfilter from a user's Maildir: ---- log "==== In included file" if ( /^Return-Path: <vchkpw-return/ ) { log "match on: $MATCH - vchkpw" to "$VDIR/Maildir/.vchkpw/" } ---- I'd love to hear any comments on this. It works for me. The overzealous logging is most important to track down problems in the maildrop config. This is not my creation by a long shot, but the result of examples posted here in the past and examples from Mr. Sam's docs. Thanks, Charles On Thu, 7 Aug 2003, Charles Sprickman wrote: > Hello, > > Just a quick note, I just gave 5.3.24 a spin, and vdelivermail still > doesn't pass the $EXT and $HOST variables along when delivering to a > catchall address. This, in effect means that you cannot filter any mail > destined to a catchall address. > > I've seen a posting where someone had mentioned using "$PWD" to grab the > info, but for whatever reason when I throw the following line at maidrop, > it barfs: > > SHELL="/bin/sh" > VHOME="$PWD/Maildir/" > USERNAME=`echo ${PWD##*/}` > USERHOST=`PWDTMP=${PWD%/*}; echo ${PWDTMP##*/}` > > Meaning, $PWD has nothing in it... I have it set to explicitly log those > values like so: > > logfile "/home/vpopmail/domains/fasttrackmonkey.com/maildrop.log" > log "=====" > log "host - $USERHOST name - $USERNAME pwd - $PWD" > > The result is: > > ===== > host - name - pwd - > > That case does not work regardless of whether it's a catchall delivery or > not... > > Charles > >