On 3-Jun-2008, at 12:20, Doug McNutt wrote:
Please ask <[EMAIL PROTECTED]> If you'd like to see the code - it's done in perl. and uses post filtering options of qmail under open BSD. <ftp://ftp.macnauchtan.com/Pair/qfilter_list.pl >


I have a few lines of procmail that auto-sorts all mailing lists (well, just about). It does not need updating for new lists nor cleaning to remove old lists.

==begin
# .list_procmail, best to be called with a
# INCLUDERC=/list_procmail

MYDATE=`date '+%Y-%m'`
# [  ] contains a space and a tab

#Sean B Straw wrote most (all?) of this block, some slight tweaks made
LISTNAME
:0
* 9876543210^0 ^(List-Id:.*<|X-Mailing-List:[   ]*)\/[-A-z0-9_+]+
* 9876543210^0 ^(List-Post:[ ]*(<mailto:)?|List-Owner:[ ]*(<mailto:)?owner-) \/[-A-Z0-9_+]+ * 9876543210^0 ^(Sender:[ ]*owner-|X-BeenThere:[ ]*|Delivered-To: [ ]*mailing list )\/[-A-Za-z0-9_+]+
* 9876543210^0 ^Sender:.* List"? <(mailto:)?\/[-A-Z0-9_+]+
{ LISTNAME=$MATCH }

# OK, that didn't work, let's try List-Subscribe
:0E
   * ^List-Subscribe:.*<mailto:\/[-A-Z0-9_+]+-(digest|on|subscribe)@
   * MATCH ?? ^^\/.+-
   * MATCH ?? ^^\/.+[^-]
   { LISTNAME = $MATCH }

#Sort the mail into /home/users/Mail/listname/2004-04.listname mbox files
:0
* ! LISTNAME ?? ^^^^
{
   :0fw
   | formail -i "X-Covisp-Listname: $LISTNAME"

   :0: $HOME/lock
   $MLDIR/$LISTNAME/$MYDATE.$LISTNAME

   # if the action failed, probably the directory does not
   # exist, so create it
   :0eW
   {
     LOG="FAILED WRITE$NL"
MAKENEWDIR=`test -d $MLDIR/$LISTNAME || mkdir -p $MLDIR/ $LISTNAME/`

   }

   # Now save the message again
   :0a:
   $MLDIR/$LISTNAME/$MYDATE.$LISTNAME

   # If we get this far, something is quite wrong.
   # Better save the message somewhere we can check it
   :0
   {
     LOG="FAILED WRITE NEW DIRECTORY$NL"
     :0: $HOME/lock
     $MLDIR/FAILED_LIST_SORT
   }
}
==end

I've been running this procmail for many years and have only had one instance of a message hitting the FAILE_LIST_SORT mbox, and that was due to a permission problem on the user's home folder.


--
The Piper's calling you to join him


--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to