procmail
[Top] [All Lists]

Re: Need a formula for forwarding and rejecting email from lists

2006-07-08 02:31:17
On Thu, Jul 06, 2006 at 09:36:35PM -0700, $Bill Luebkert wrote:

:0
* $RECIP ?? ^\/[^(_at_)]+
{ USER_= `echo $MATCH | tr A-Z a-z` }

:0
* $MAIN_DOMAIN ?? ^^^^
{
  :0
  * $RECIP ?? @\/.*
  {
    DOMAIN_= `echo $MATCH | tr A-Z a-z`
  }
  MAIN_DOMAIN=$DOMAIN_
}

I understand that you what to ensure the entries are lower-case.
Your approach is inefficient, however.

You always run each message through tr twice.  Chances are, the
address is already lower-case.  Even if it's not, we only need tr
once if we rewrite the algorithm.

First, test for a need.  If it's there, run tr.

    recip = $RECIP
    :0 D
    * recip ?? [A-Z]
    { recip = `echo "$RECIP" | tr A-Z a-z` }

Now find your local part and domain part as you like using $recip
as input insted of $RECIP.

QUOTA=`grep -e "^${USER_}:" ../.mm/${MAIN_DOMAIN}.passwd | awk -F ":" 
'{t=\$4} E
ND {print t+0}'`   # fill in the number, in bytes

I see no need to use *both* grep and awk here.  Do it all in
awk and lose a pipe, or use sed.

 QUOTA = `awk -F: '$1 ~ /^'${USER_}'$/ {
        print $4 0 }' ../.mm/${MAIN_DOMAIN}.passwd`

dman

____________________________________________________________
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