procmail
[Top] [All Lists]

Re: recipe help: to me OR to ONE list (should be simple)

1996-10-16 18:38:09
On Wed, 16 Oct 1996, Alan K. Stebbens wrote:

If you wish to use regular expressions instead of strings, then use
"egrep" instead (but be sure to use regular expressions):

  :0
  * ! ? egrep -s -f accept
  BOUNCE-ACTION

      So, 'accept' is a text file containing expressions??

Yes.

      Can you give an example?

With 'egrep', each line in "accept" must be a regular expression:

    aks@(.*\.)?sgi\.com
    @(.*\.)?aol\.com
    @(.*\.)?csupomona.edu

These lines above will match my address on any host within SGI, any AOL
address, and any address at Cal State Pomona.  

If you have mixed-case addresses, such as yours above, then use the "-i"
option on the egrep call:

    :0
    * ! ? egrep -i -s -f accept
    BOUNCE-ACTION

I should have put the '-i' option in my original mail anyway, since all
DNS name matching is defined to be case-insensitive.

With 'fgrep', each line in "accept" is a literal string to match; eg:

    aks(_at_)anywhere(_dot_)engr(_dot_)sgi(_dot_)com
    aks(_at_)sgi(_dot_)com
    foo(_at_)company(_dot_)com
    bar(_at_)dept(_dot_)company(_dot_)com
    @company.com
    @dept.company.com

Using fgrep, you can match specific domains, or subdomains, but you
cannot match arbitrary subdomains, such as any subdomain with "sgi.com",
unless you allow for the possiblity of false matches.

In other words, the fgrep string "@sgi.com" will match any address
ending in "@sgi.com", but not those ending in subdomains within SGI,
such as "@engr.sgi.com" or deeper.   If you use the fgrep string
"sgi.com", then you also allow for false matches, such as "notsgi.com",
"usgi.com", etc.

The advantage of regexps is that you can create flexible patterns to
match categories of addresses, such as all subdomains within a given
domain; eg: "@(.*\.)aol\.com".

But, maintaining a file of regexps is more work: regexps must be used
for all lines, even if for literal addresses.  For example, if you wish
to match the address "foo(_at_)dept(_dot_)company(_dot_)com", the corresponding 
regexp
would be:

    foo(_at_)dept\(_dot_)company\(_dot_)com

The process of adding or removing patterns to the regexp file must take
this into account, whether by hand or automatic.  I have an example of
this automatic maintenance of a regexp pattern file in my procmail
library recipe file named "commands.rc" (send an email with the subject
of "send procmail library", or browse my web page under the mail link.

If you are thinking of setting up a mini-mailing list through your
address, get SmartList (at the same place you got procmail), and install
it.  It does all of these things, even using a file called "accept" by
which submissions are accepted or not.

Hope this helps.
___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks