I love Firefox but one thing that has been bugging me is getting it to handle mailto URL's in Linux. For some reason there is no actual way to configure this easy in the preferences. So, I Googled about figuring someone has to have done it already but I could only find references to getting Thunderbird and Firefox working together. I like mutt, so I decided to try my hand for the first time ever at actually writing up something that was kind of useful. Well, useful for me anyway.
Inspired by the example helper scripts I saw for Thunderbird I came up with this:
#!/bin/bash MAILTO_URL="$@"
#Strip off the protocol MAIL_DATA=$(echo "$MAILTO_URL" | /bin/sed -s 's/^mailto://I')
#Get Recipient and strip it off RECIPIENT=$(echo "$MAIL_DATA" | cut -d? -f1 -) MAIL_DATA=$(echo "$MAIL_DATA" | /bin/sed -s "s/^$RECIPIENT//")
#Get Subject,BCC, and CC SUBJECT=$(echo "$MAIL_DATA" | \ /bin/sed -s 's/.*?subject=//I' | /bin/sed -s 's/?.*//') BCC=$(echo "$MAIL_DATA" | /bin/sed -s 's/.*?bcc=//I' | \ /bin/sed -s 's/?.*//') CC=$(echo "$MAIL_DATA" | /bin/sed -s 's/.*?cc=//I' | \ /bin/sed -s 's/?.*//')
#Call mutt in an aterm aterm -fg white -bg black -geometry 80x50 -fn 9x15 -e \ mutt "$RECIPIENT" -b "$BCC" -c "$CC" -s "$SUBJECT"
I named this script mailto_helper, made it executable, and stuck it in a logical place for me. Then I opened the URL "about:config" in Firefox. In there I right clicked and created a new string called "network.protocol-handler.app.mailto" with a value of the path to where I put mailto_helper and to my surprise it worked. I'm sure a real programmer/scripter could do something better but I don't think it's all to bad for a novice like me.
Update for Clarity (1/2/2005)
There is an excellent extension called Mozex that no longer seems to work with Firefox as of
version 1.0. Mozex was last updated somewhere around Sept 2003. I wrote
this script since it doesn't seem Mozex is going to be updated and I don't have
the skill it takes to fix it. For now this works but I will miss the extra
function that Mozex offered.
Update on mozex (1/7/2005)
It was pointed out to me from B10m that you can use Show Old Extensions
to get mozex to work in
Firefox 1.0. I just installed it and it works great. While I'm proud of my
little script to handle the mailto links mozex is much better and lets you
handle ftp, news, irc, and telnet links in addition to mailto links.
(3/5/2005)
Changed MAILTO_URL="$1" to MAILTO_URL"$@" to accomondate subjects of more than
one word. Thanks to Wayne Gemmell for the suggestion.
(4/17/2005)
Modified the ninth line down by putting double quotes around the regular
expression because, for some people, sed complained about an unfinished
command. It looks to run fine for me with or without the quotes but since they
don't hurt anything I put them in. Thanks goes to Lukasz Wiechac for pointing
this out.