procmail
[Top] [All Lists]

Re: Rejecting unknown users

2001-02-07 16:40:44
On  7 Feb, Stephen R. Wilcoxon wrote:
| On Wed 2001/02/07 14:55:49 EST, Postmaster 
<allemail(_at_)kenton(_dot_)k12(_dot_)oh(_dot_)us> 
| writes:
| > I have been playing around with it all day, but have run into a snag. When I
| > use the following recipes, everything gets rejected. All the high school
| > students usernames begin with 01,02,03, or 04. I want to trash any username
| > that begins with those characters, and then let through anything with
| > @kenton.k12.oh.us (which would presumable be the teachers). The
| > .localprocmailrc is for future use, where I can list addresses of allowed
| > senders for individual students.
| > 
| > I have the following .procmailrc:
| > 
| > #Preliminaries
| > SHELL=/bin/sh               #Use the Bourne shell (check your path!)
| > MAILDIR=${HOME}/mail            #First check what your mail directory is!
| > LOGFILE=${MAILDIR}/procmail.log
| > LOG="--- Logging ${LOGFILE} for ${LOGNAME}, "
| > PMDIR=/etc/procmail
| > 
| > #System Wide
| > INCLUDERC=${HOME}/.localprocmailrc
| > INCLUDERC=$PMDIR/reject.rc
| > INCLUDERC=$PMDIR/accept.rc
| > INCLUDERC=$PMDIR/trash.rc
| > 
| > Here is the reject.rc:
| > #Reject High School Students
| > :0
| > * ^From*(01|02|03|04)*
| > | (formail -rk \
| >         -A "X-Loop: MAIL-REJECTION" \
| >         -A "Precendence: junk"; \
| >         echo "This e-mail account is restricted on";\
| >         echo "who it can receive e-mail from and has";\
| >         echo "not received this message.";\
| >         echo " ";\
| >         echo "If you believe this to be in error, please";\
| >         echo "notify postmaster(_at_)kenton(_dot_)k12(_dot_)oh(_dot_)us" ) 
| $SENDMAIL -t -oi
| > 
| > Here is my accept.rc:
| > #Accept from KCS Teachers
| > :0:
| > * ^From*(_at_)kenton\(_dot_)k12\(_dot_)oh\(_dot_)us
| > ${DEFAULT}
| 
| Your from conditions are probably not what you want you are looking for 
| lines starting with "Fro" followed by 0 or more 'm'.  You probably wanted 
| "^From:[      ]*(01|02|03|04)" (there is a space and a tab inside the []) or 
| "^From:.*(01|02|03|04)[a-z]*@" (a-z should be replaced with whatever 
| characters are valid after the 0[1-4] for your high school students) and 
| "^From:(_dot_)*(_at_)kenton\(_dot_)k12\(_dot_)oh\(_dot_)us".

Just to clarify for Ryan, the asterisk is regular expressions does not
work the same as in filename globbing. It means zero or more of the
character (or class, or alternation, etc.) immediately preceding it.
The dot (.) is special in regular expressions and matches any character.

I would offer a couple adjustments to Stephen's suggestions.

:0
* ^From[: ].*\<0[1-4](_dot_)*(_at_)kenton\(_dot_)k12\(_dot_)oh\(_dot_)us

There is no reason to eliminate the envelope from the condition. This
should match either. The numeric pattern is changed because, as Philip
pointed out a couple of weeks ago, character classes are more efficient
than alternations. Finally, a word boundary is added just before the
numeric pattern to make sure the numbers only match at the beginning of
the address.

Don Hammond



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>