procmail
[Top] [All Lists]

Re: sorting based on domain and receiver

2010-02-10 10:19:56
hmm, Klaus Johannes Rusch said that
frantisek holop wrote:
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....
  
You will need to extract the desired information in multiple steps.  
Alternatively you can convert the e-mail address using an external  
program, something like (untested)

:0 fh
* ^To:.*\/[a-z]*(_at_)[a-z]*\(_dot_)com
| formail -A `perl -npe "s/^(.*)\@(.*)\..*$/X-Folder: \\2-\\1/"`

:0
* ^X-Folder: \/
/path/$MATCH


thanks to you all for the great answers.

first i wanted to go with a procmail only solution but i need
to normalize the input a bit first..  like lowercasing everything
and such, otherwise i am gonna end up with hundreds of mailboxes

the comments about the To:, CC: fields were also correct,
the emails are sent by clients (although most of them will
simply click on a mailto: link probably), and thus can contain
any combination and form of to:,cc:,bcc: etc...

on the other hand, because of the answers to these emails
will have to be from the same address they received were
received for (from: country1(_at_)brand1(_dot_)com -> reply from: 
country1(_at_)brand1(_dot_)com)
i am not sure i can go with the one mail account
multiple folders approach.

-f
____________________________________________________________
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>