procmail
[Top] [All Lists]

Re: A rule to copy all message to a maildir, and then keep processing

2009-11-19 10:20:33
* Salvatore Iovene <salvatore(_at_)iovene(_dot_)com> [11-19-09 07:26]:
thanks, that sounds just like what I wanted. Only a minor problem
though: this will include spam, as my spamassassin rules are at the
end of .procmailrc, because they're rather cpu intensive (I hear), so
it's better to process mailing-lists and other easy rules first.

Do you have any idea about how to fix this?

??

You want to process for spam at the beginning of your recipies so you do
not deliver to other directories before identifying as spam.  Your
request appears that you want to retain *copies* of all mail (archival?),
if you want copies of *all* mail, do the copying before spamcheck.  If
not, do it after.  Also using spamd is not that cpu intensive, just
filtering with spamassassin would be.


cat ~/.procmailrc

SHELL="/bin/bash"
SPOOL="/var/spool/mail"
MAILDIR="$HOME/mail"
DEFAULT="$SPOOL/pat"
COMSAT=no
#BULKFOLDER=$MAILDIR/local.mail
ENV_TO=$1

#Directory for storing procmail log and rc files
PMDIR="$HOME/.procmail"

LOGFILE="$PMDIR/log"


#Set on when debugging
VERBOSE=off

# when debugging; set to no if you want minimal logging
LOGABSTRACT=yes

# http://pm-doc.sourceforge.net/pm-tips.html

NL      = "
"
WSPC    = "     "               # whitespace: space + tab
SPC     = "[$WSPC]"             # Regexp: space + tab
SPCL    = "($SPC|$)"            # whitespace + linefeed: spc/tab/nl
NSPC    = "[^$WSPC]"            # negation

s       = $SPC                  # shortname: like perl -- \s
d       = "[0-9]"               # A digit -- Perl \d
w       = "[0-9a-z_A-Z]"        # A word  -- Perl \w
W       = "[^0-9a-z_A-Z]"       # A word  -- Perl \W
a       = "[a-zA-Z]"            # A word, only alphabetic chars    

FORMAIL        = "/usr/bin/formail"
RAZORCHECK    = "/usr/bin/razor-check"
PYZORCHECK      = "/usr/bin/pyzor"
SPAMASSASSIN   = "/usr/bin/spamassassin"
SPAMC          = "/usr/bin/spamc"
SED            = "/usr/bin/sed"
LBDBFETCHADDR = "/usr/bin/lbdb-fetchaddr"

# -------------------------------------------------------
# added per Dallman Ross
# on procmail-list June 2, 2007
# Get current date-relevant info per From_ line (usu. generated by procmail)
# -------------------------------------------------------


 AWEEKDAY     = "(Mon|Tue|Wed|Thu|Fri|Sat|Sun)"
 MMtable      = "{ Jan:01 Feb:02 Mar:03 Apr:04 May:05 Jun:06
                  Jul:07 Aug:08 Sep:09 Oct:10 Nov:11 Dec:12 }"


 :0  # 030110 () save tail-end of FROM_ in order to parse DATE
 * $  ^^From .* \/$AWEEKDAY .+
 { FROM_ = $MATCH

    :0  # 021211 () find year in FROM_
     * FROM_ ?? ()\/....^^
     { THISYEAR = $MATCH }

    :0  # 021211 () find YY
     * THISYEAR ?? ()\/..^^
     { YY = $MATCH }

    :0  # 021211 () find MONTH
     * FROM_ ?? () \/...
     { MONTH = $MATCH }

    :0  # 021211 () find MM
     * $  MMtable ?? ()\<$MONTH:\/[01][0-9]
     { MM = $MATCH }

    :0  # 021212 () find DD
     * $ FROM_ ?? ()\<$MONTH +\/[1-3]?[0-9]
     *   MATCH ?? ^^..
     { DD = $MATCH }

    :0 E  # 021211 () replace space as necessary
     { DD = 0$MATCH }

    DATE = $YY$MM$DD
 }



# -------------------------------------------------------
# added per Ruud H.G. van Tol <rvtol(_at_)isolution(_dot_)nl>
# on procmail-list Apr 4, 06
# 
# Capture value of Subject: 
# and use ${H_SUBJ} in your further recipes.
# -------------------------------------------------------
 H_SUBJ   # unset
 :0
 * $ ^Subject:.*\/[^$WS].*
 { H_SUBJ = "$MATCH" }
# -------------------------------------------------------


LOG="$NL$DATE$WSPC++++++++++++++$$+++++++++++++++++$NL"

# -------------------------------------------------------
# added per Alan Clifford <lists(_at_)clifford(_dot_)ac>
# on procmail-list Feb 28, 06
# 
# delay execution procmail, one per msg
# -------------------------------------------------------
     ########### lockfile #############################
     # Ensures only one message at a time
     LOCKFILE=$PMDIR/testing.lock
     ##################################################
# -------------------------------------------------------


# -------------------------------------------------------
# 09-13-08 
# added per msg in mutt.users fm 
#      Erik Christiansen <dvalin(_at_)internode(_dot_)on(_dot_)net>
# -------------------------------------------------------
# Unconditionally extrace Message-id:
:0                                  
   {  MSG_ID=`formail -x"Message-id:"` }
LOG=$MSG_ID
:0                                                                              
                                                                                
  
   {  TO=`formail -x"To:"` }
LOG=$TO
# -------------------------------------------------------



INCLUDERC="$PMDIR/rc.maillists"






cat ~/.procmail/rc.maillists   (trimmed)


# -------------------------------------------------------
# SpamAssassin sample procmailrc
#
# Pipe the mail through spamassassin (replace 'spamassassin' with 'spamc'
# if you use the spamc/spamd combination)
#
# The condition line ensures that only messages smaller than 250 kB
# (250 * 1024 = 256000 bytes) are processed by SpamAssassin. Most spam
# isn't bigger than a few k and working with big messages can bring
# SpamAssassin to its knees.
#
# The lock file ensures that only 1 spamassassin invocation happens
# at 1 time, to keep the load down.
#
:0fw: spamassassin.lock
* < 256000
#| $SPAMASSASSIN
| $SPAMC

# Mails with a score of 15 (9) or higher are almost certainly spam (with 0.05%
# false positives according to rules/STATISTICS.txt). Let's put them in a
# different mbox. (This one is optional.)
#:0:
#* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*
#$MAILDIR/almost-certainly-spam

# All mail tagged as spam (eg. with a score higher than the set threshold)
# is moved to "probably-spam".
:0:
#* ^X-Spam-Status: Yes
* ^X-Spam-Flag: YES
$MAILDIR/probably-spam

# Work around procmail bug: any output on stderr will cause the "F" in "From"
# to be dropped.  This will re-add it.
:0
* ^^rom[ ]
{
  LOG="*** Dropped F off From_ header! Fixing up. "
    
  :0 fhw
  | $SED -e '1s/^/F/'
}
# -------------------------------------------------------
VERBOSE=off




-- 
Patrick Shanahan         Plainfield, Indiana, USA        HOG # US1244711
http://wahoo.no-ip.org     Photo Album:  http://wahoo.no-ip.org/gallery2
Registered Linux User #207535                    @ http://counter.li.org
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail