procmail
[Top] [All Lists]

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

2006-07-08 11:27:29
Dallman Ross wrote:

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.

That's not my code - it's the ISP's code and I can't change it.

You're missing the real point.  I only need the 2 rules coded.  The
above code is from the ISP's script (only put there for reference).

What I need:

1) if legit user (grepped from good file), forward and exit
2) if bad user (grepped from bad file), (temporarily forward) and send
   reject to sender and exit
3) Else continue on with script forwarding rules.

File line format:
Username<sp>NewUser(_at_)ForwardingAddress(_dot_) eg: 'joe 
ForwardToUser(_at_)somedomain' (quotes not present)

-------------------------------------------------------------------

Or replacing the pseudo code below is basically all I need:

# if user in GOOD list
#   forward to second field in GOOD line

# if user in BAD list
#   forward to second field in BAD line and return 'user unknown' to sender

# my feeble attempt:

# grab the 2nd (forwarding address) field for line starting with $RECIP

GOOD = `egrep -is "^$RECIP" legit.lst | $cbin/sed.exe -n "s/^$RECIP //i;p"`
BAD = `egrep -is "^$RECIP" bad.lst | $cbin/sed.exe -n "s/^$RECIP //i;p"`

{
  :0
  * GOOD ?? ^[a-zA-Z].*$        # trying to test if GOOD has some characters
  ! $GOOD                       # if so, forward it to $GOOD
}
{
  :0
  * BAD ?? ^[a-zA-Z].*$         # trying to test if BAD has some characters
  EXITCODE=76                   # make sure sender gets 'user unknown' error 
[not sure of 76 value]
  ! $BAD                        # temporarily forward till all checked out
# /dev/null                     # use this after forwarding line removed ???
}

---------------------------------------------------------------------

Sorry if I didn't make it clear what needs to be done.  The rest of
the post was just showing the existing RC scripts supplied by ISP.

____________________________________________________________
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