Make Gmail Handle Your mailto: links in Linux
May 21st, 2007
I spotted this article describing how to make Ubuntu send mailto: links through Gmail. It’s not wrong exactly, but I wanted to improve upon it a little. I have my own version which requires no external files, and all it needs is that you send your mailto: links through this command…
sh -c "firefox 'https://mail.google.com/mail?view=cm&tf=0&to='$(echo \"\$1\" | sed -e 's/mailto:\(\/\/\)\?//' -e 's/\?/\&/' -e 's/\&subject=/\&su=/I')" custom-mailto-launcher "%s"
On Ubuntu, go to System -> Preferences -> Preferred Applications, change your mail reader to “Custom”, then put this line in. If you use another version of Linux, you’ll have to figure that part out yourself. Keep in mind %s is the variable and firefox is the default browser in my example.
Mine removes the “mailto” part a little better, and makes a hacky attempt to parse the subject/cc/bcc arguments these links sometimes have. Most importantly though, it’s a one-step process.
August 12th, 2007 at 8:23 am
This is a great tip. You need to url encode the links though, otherwise firefox gets all kinds of cranky when it gets spaces and such. I just replaced spaces with %20 and haven’t had a problem yet - would not bet my head that it won’t break somewhere else, though:
sh -c “firefox ‘https://mail.google.com/mail?view=cm&tf=0&to=’$(echo \”\$1\” | sed -e ’s/mailto:\(\/\/\)\?//’ -e ’s/\?/\&/’ -e ’s/\ /%20/g’ -e ’s/\&subject=/\&su=/I’)” custom-mailto-launcher “%s”
good job with this hack!
October 30th, 2008 at 5:17 am
Super! It works great, thank you!!
November 17th, 2008 at 10:17 pm
This is great, and works with one slight issue: gmail inserts a “/” in front of the email address, making it undeliverable. I’ve tried, by process of elimination - trial and error - to get rid of this, but it either inserts the “/” or leaves the email address out entirely. If it helps, I’m trying to insert the email address using gnome do. Thanks.