procmail
[Top] [All Lists]

Re: Yahoo! Clubs, or how to create a mailbox from the subject

2001-07-11 08:53:42
On 10 Jul, jherazo(_at_)geocities(_dot_)com wrote:
| Hi. I have a question i haven't found an answer for. If this message pops up 
| twice or more, please ignore the first as i was having some trouble here with
| something i was trying (mutt+fetchmail+procmail+qmail, i think it's working 
| now, i hope :)
| 
| The Yahoo! Clubs interface allows to have the messages delivered to the e-mail
| so you can check them without opening the browser and heading there. But it 
has
| a (IMHO) braindead interface very unfriendly to list processors, as all the 
mail
| comes from clubs-mail(_at_)yahoo-inc(_dot_)com, and the only indicaton of the 
group is in
| the subject, added at the end as "[Yahoo! Clubs: The Name Of The Club]" (of
| course, with the actual name of the club). I added manual checks for this in 
my
| procmailrc, but after the 5th club, i wanted to do some filter that would pick
| the name of the club, replace spaces with underscore chars, and use that as 
the
| name of the maildir to deliver to, but i haven't been able to do this.
| 
| I know it's possible (perl has convinced me that everything is possible if you
| know how :) , but i just don't know how to approach this except whiping out 
some
| perl script (but this isn't perl). Ideas?

:0
* ^Subject:.*\[Yahoo! Clubs: \/[^]]+]$
* MATCH ?? ^^\/[^]]+
{
   xFILE=`echo "$MATCH" |tr -s '\t ' '_'`
  :0:
   $xFILE
}   

The translation of space chars to underscores could undoubtedly be done
with a resursive call to an rcfile, but this seems reasonable. ;-)

Caveats (that I can think of):
1. Your tr must understand \t for tab (unless you don't think it's
necessary and it's removed). GNU tr does - I don't know if others do.
2. This won't match if there is whitespace between the [Yahoo! ...] crap
and the end of the Subject: line. It could be fixed, if necessary, by 
inserting [     ]* (space,tab char class) just before the $ anchor.
3. If there are any ] chars before the final closing one the \/ operator
will truncate $MATCH at that point, delivering to a filename at least
slightly different than you might expect.
4. If there are any / chars within the [Yahoo! ...] crap a matching
directory hierarchy would be expected. I don't think procmail creates
directories, so you'd probably get a write error and presumably
failsafe delivery to $DEFAULT. If that's a risk, you would either want
to add / to the tr command to translate it to _, or use a second tr pipe
(same command line) to translate / to something else of your choosing.
You might want to do the same thing with some other chars like \ also,
just on general principles.
5. You might need/want to prepend a path to $xFILE. 

-- 
                         /"\
Don Hammond              \ /     ASCII Ribbon Campaign
Raleigh, NC US            X        Against HTML Mail,
                         / \      and News Too

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail