pushmedia1
6.29.2005
  Fun with Unix
So. I learned a little bit about a lot of things last night. I wanted to share because I found some cool resources. Warning: technical discussion follows.

Some facts: I play WoW. I'm in a WoW guild blog. We also have a Yahoo! group page. I wanted everyone in the guild to get emailed whenever anyone commented on the blog. We use blogger and it doesn't have very much in the way of group blog features. Because yahoo groups is a glorified listserv, I wanted to post comments to our blog to the group page and let yahoo email the comment to the group. Posts to the group page get sent to the group members (i.e. my fellow guildies).

Blogger developers, if your listening, a very nice feature: email comments to all blog authors.

Anyway, I ran into some troubles:
Grabbing for straws here...

Is there a way to force gmail to convert html emails to plain text before forwarding (via a filter)?

I'm kludging together a feature that blogger should have... When someone posts a comment to my group blog, I'd like the whole group to receive an email. Blogger won't do this (mostly because it doesn't store member email addresses). My group also has a "yahoo group" which I use as a mailing list. Yahoo groups only supports email posts from registered users. Needless to say, I can't figure out a way to tell
yahoo groups to accept emails from blogger (noreply-comm...@blogger.com).

So... I'd like to setup blogger to send my gmail account (which is registered with yahoo groups) the email. I'd use gmail's filter feature to redirect the blogger comment to yahoo groups. *pant, pant*

The twist: blogger sends comments as HTML, but Yahoo groups won't accept HTML formated email submissions! Arg!

Thus, can I get gmail to convert the html emails to plain text before forwarding on to yahoo groups.

(BTW, if you have a better solution to my problem, I'm all ears.)


Brian gave me some hints, but gmail turned out to be a dead end.

I sucked in my gut, pulled up my britches and headed over to he.net, where my website is hosted, to delve into the mysterious world of Unix mail. I knew it must be possible to write a script to redirect email. Mailbots, as they're called. Some googling later, I discovered a UNIX utilities called procmail...

(That elipsis represents about 5 hours of messing with the procmailrc file. See these comments.)

This is the .procmailrc file I created.

SHELL=/bin/sh
MAILDIR=$HOME/
PATH=/usr/bin:/usr/local/bin:/usr/local/bin
LOGFILE=$HOME/.procmaillog
VERBOSE=yes

:0
* ^From.noreply-comment.blogger.com
| formail -rk -I "Content-Type: text/plain; charset=UTF-8"
| sed 's/<[^>]*href="\([^ "]*\)"[^>]*>/- \1 -/g'
| sed "s/<[^>]*>//g"
| $SENDMAIL -oi topofcoolcute@yahoogroups.com



Basically, this is a script that preprocesses email as they come into the server. My script matches emails that come from blogger, it changes the content type email header, strips the html tags (keeping URLs) and then forwards the email on to the yahoo group page. The goobly gook you see are regular expressions. If you don't know regular expressions, run to your nearest google search box and look it up. They're essential.

I edited the page in emacs. Here's an emacs cheatsheet that I found because its been years since I used the program.

Also, a shout out to he.net... They rock. If you need web hosting, use hurricane electric.

Easy!

UPDATE: It doesn't appear to working now! Arg! Back to the UNIX labyrinth...

UPDATE 2: It works now.
 
Comments: Post a Comment

<< Home

Links to this post:

Create a Link

ARCHIVES
Google
Web www.ambrosini.us
06.2003 / 07.2003 / 08.2003 / 09.2003 / 10.2003 / 11.2003 / 12.2003 / 01.2004 / 02.2004 / 03.2004 / 04.2004 / 05.2004 / 06.2004 / 08.2004 / 09.2004 / 10.2004 / 11.2004 / 12.2004 / 01.2005 / 02.2005 / 03.2005 / 04.2005 / 05.2005 / 06.2005 / 07.2005 / 08.2005 / 09.2005 / 10.2005 / 11.2005 / 12.2005 / 01.2006 / 02.2006 / 03.2006 / 04.2006 / 05.2006 / 06.2006 / 07.2006 / 08.2006 / 09.2006 / 10.2006 / 11.2006 / 12.2006 / 01.2007 / 02.2007 / 03.2007 / Front Page


Post Feed: Posts feed
Comments Feed: Comments feed

Powered by Blogger

Creative Commons License.

Price for 2008 Republican Pres Nominee(Others on Request) at TradeSports.com Price for 2008 Democratic Pres Nominee(Others on Request) at TradeSports.com