procmail
[Top] [All Lists]

Re: Help please

1999-03-10 01:42:41
On Tue, 9 Mar 1999 12:25:19 -0600, "Mohr, Bryan" 
<Bryan_Mohr(_at_)AFCC(_dot_)com>
wrote:
Subject: Help please

(obPeeve: Please try to be more specific when writing Subject: lines.)

    1: First verify that the sender's email address is found
       in mlist.ppl (a text file with one email address per
       line). If they are not listed, forward the email to
       problems(_at_)herp(_dot_)com and stop processing.

This depends a little bit on how exactly you want to define "sender's
email address". This is a whole separate can of worms -- suffice it to
say that From_ and From: and Sender: and Reply-To: and Resent-From:
etc etc might all be different, and you need to make up your mind on
what you really mean. For ordinary purposes, the following is what a
lot of people successfully use:

    FROM=`formail -rzxTo:`     # Yes, "To:". See the FAQ.

(I'm omitting -t here, because we're not really interested in sending
anything back to this address; we just want to know which address
formail "thinks this is coming from". This is a note to those who
understand the distinction between -r and -rt. The FAQ has some notes
on this. <http://www.iki.fi/era/procmail/> -- there are a couple of
different places where these things are discussed. Generally, look for
references to formail.)

Then, we want to verify that the FROM we just got is in the file you
talked about, or else forward to problems(_at_)herp(_dot_)com(_dot_) Another 
way to
state this is, forward to problems(_at_)herp(_dot_)com (and obviously, don't do
the rest of this rc.file) unless the address is one which is in the
file. Another way to state that is

    :0
    * ! ? fgrep -xqs "$FROM" mlist.ppl
    ! problems(_at_)herp(_dot_)com

If you aren't going to need the FROM variable for anything else, you
could even compress this into something like

    :0
    * ! ? formail -rzxTo: | fgrep -xqsf - mlist.ppl
    ! problems(_at_)herp(_dot_)com

The -x option says you want the match to match a whole line in the
file (so bar(_at_)aol(_dot_)com doesn't accidentally match on an address which
contains this as a substring, like foobar(_at_)aol(_dot_)compromise(_dot_)net). 
-q
means be quiet (don't print out matches, just return an exit code
which reflects whether there was a match); -s means don't complain
about missing or nonexistent files (I'm not sure whether this is a
good idea actually ...) and -f - means the strings to match come from
a file and that file is called "-" i.e. standard input. Your fgrep
might not have all of these options, or it might call them something
else. 

You should perhaps implement a separate check against e.g. missing or
empty mlist.ppl.

As usual, the best solution to mailing list problems is often to get a
real mailing list manager instead of trying to roll your own. It's by
no means trivial to get it right.

Hope this helps,

/* era */

-- 
.obBotBait: It shouldn't even matter whether    <http://www.iki.fi/~era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>

<Prev in Thread] Current Thread [Next in Thread>
  • Help please, Mohr, Bryan
    • Re: Help please, era eriksson <=