procmail
[Top] [All Lists]

Re: sorting based on domain and receiver

2010-02-04 05:58:13
In message <20100204094919(_dot_)GU12156(_at_)pentacom(_dot_)sk>,
        frantisek holop (f(_at_)pentacom(_dot_)sk) wrote:

i am trying to automate the following process:
let's say there is a helpdesk, or some such entity that
gets email in the form: country(_at_)brand(_dot_)com

gets?  Where is this information, is it in the Subject: header?  (If you
want help you need to help us since I do not think any of the regulars
on the lists are clairvoyant or own a working crystal ball. :-) )

i'd like to create a recipe to automatically sort
incoming mails into folders in the form of: brand-country

e.g.
austria(_at_)mybrand1(_dot_)com -> mybrand1-austria
germany(_at_)mybrand1(_dot_)com -> mybrand1-germany
germany(_at_)mybrand2(_dot_)com -> mybrand2-germany
etc.

as far as i can tell from the man pages, MATCH is not
too flexible for this....

How about the following (which is untested, but ought to be close to a
working solution).  It assumes that your information is in the From:
header.


:0
* ^From:[        ]*\/[^(_at_)]+
{ MY_COUNTY=$MATCH }
:0
* ^From:[        ]*[^(_at_)]+@\/[a-z]+
{ MY_BRAND=$MATCH }
:0
* ! MY_COUNTRY ?? ^^^^
* ! MY_BRAND ?? ^^^^
$MY_BRAND-$MY_COUNTRY/


NB:
 1. The [        ] contain one TAB character and one SPACE character.
 2. If your brand names contain characters other than a-z you will have
    to change the second regexp accordingly.
 3. I have assumed maildir _folders_ since you did not specify and that
    is what I use.


Cheers,
       Nick.
-- 

____________________________________________________________
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

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