procmail
[Top] [All Lists]

Re: External Account Listing?

2001-02-01 10:57:58
Robert Hough wrote:
Is it possible to set up a recipe that reads from a flat file, various
email accounts you have, and then matches against that?


Yes.

    :0 hWc
    | formail -xto: -xcc: | sed -e 's/^/,/' -e 's/$/,/' | \
        grep -if /list/of/my/aliases

    :0a
    { 
      #stuff to do if "To:" or "cc:" matched any of my aliases
    }

where /list/of/my/aliases contains stuff like this: 

  [^-(_dot_)_a-z0-9]rch(_at_)solveinteractive\(_dot_)com[^-(_dot_)a-z0-9]
  [^-(_dot_)_a-z0-9]rh29(_at_)yahoo\(_dot_)com[^-(_dot_)a-z0-9]

  (Don't indent it!  I only indented it to set it off from the text.
   I just made up the rh29 one for illustration...)

You don't want mail for 
zorch(_at_)solveinteractive(_dot_)comml-consultants(_dot_)org
for example.  

But if you think stuff like that is sufficiently rare, then you can
put just your email addresses into /list/of/my/aliases, and in the
procmail recipe use:

    :0 hWc
    | formail -xto: -xcc: | grep -F -if /list/of/my/aliases

(Do you care about Apparently-To: or Resent-To: or Original-cc: or
Apparently-Resent-To: or X-Envelope-To: etc?)

I get mail to about 15 different aliases, addresses, etc. These I can not
change, unfortunately. Instead of creating 15 individual recipes, that all
pretty much do the same thing, is it possible to create a single entry and
then have a file with enties for each address those are going to?

Well, the above should be a starting point.
The other thing you could do is...

    :0
    * ! ^TO_rch(_at_)solveinteractive\(_dot_)com\>
    * ! ^TO_rh29(_at_)yahoo\(_dot_)com\>
    [[ etc ]]
    { 
      # ^TO_ didn't match of ANY of my aliases !!
    }

    :0 E
    {
      # stuff to do if ^TO_ matched *any* of my aliases
    }

which is just a little worse than having a file like the above.

All of the above is UNTESTED but ...

hth
-- 
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.
Collin Park                         Not a statement of my employer.
_______________________________________________
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>