Search:  
Gentoo Wiki

HOWTO_Open_mailto:_links_in_gmail

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Are you a GMail user who's tired of not being able to use email (mailto:) links? Here's a way to make them work again! As an added bonus, mail-client/mail-notification (and possibly others) will correctly open GMail when told to open a mail client.

Contents

The script

This article shows how to set up a gmail mailto: script that all users can use. To create a script just for yourself, simply use ~/.gmail-mailto instead of /usr/bin/gmail-mailto.

# nano -w /usr/bin/gmail-mailto
File: /usr/bin/gmail-mailto
#!/bin/sh
BROWSER="firefox"

#when we are passed an email address like this:
#mailto:vdog@domain.com?subject=hi%20vernon&body=please%20unsubscribe%20me%20from%20this%20mad%20list&cc=mad@max.com&bcc=jo@mama.com

#we want to generate a uri like this:
#http://mail.google.com/mail/?view=cm&tf=0&to=vdog@domain.com&cc=mad@max.com&bcc=jo@mama.com&su=hi%20vernon&body=please%20unsubscribe%20me%20from%20this%20mad%20list&zx=9i09cu-h33iui

#Unless you are using gmail for a hosted domain, then you want to use this:
#http://mail.google.com/a/domain.tld/?view=cm&tf=0&to=vdog@domain.com&cc=mad@max.com&bcc=jo@mama.com&su=hi%20vernon&body=please%20unsubscribe%20me%20from%20this%20mad%20list&zx=9i09cu-h33iui

#NOTE from and the editor of the above line: the /a/ may differ from domain to domain, I'm not sure I only have one hosted domain.

# remove the ? from the uri
uri=`echo "$1" | sed -e 's/subject=/su=/' -e 's/^mailto:\([^&?]\+\)[?&]\?\(.*\)$/\1\&\2/'`

if [ "$uri" ];
 then exec $BROWSER "https://mail.google.com/mail?view=cm&tf=0&ui=1&to=$uri"
fi

exec $BROWSER "https://mail.google.com/"

(Adapted from [1])

# chmod a+x /usr/bin/gmail-mailto

This script loads GMail in Mozilla Firefox. To use a different browser, simply change firefox to the desired browser at the start of the script, e.g.:

BROWSER="konqueror"

Using the script

Gnome

Open System -> Preferences -> Preferred Applications. Under Mail Reader, select Custom and enter:

gmail-mailto %s

KDE

Open Settings -> KDE Components -> Component Chooser. Under Email Client, select Use a different email client and enter:

gmail-mailto %t

You may also wish to set the browser to konqueror at the start of the script, if you haven't already.

XFCE

Open the Settings panel (xfce-setting-show, I can't find it in the GUI) and click on Preferred Applications. Under Mail Reader, select Other, and enter:

gmail-mailto

Note: If you're using Firefox and have Gnome installed, you may need to open Gnome and follow that set of instructions. Firefox seems to look for Gnome's settings before XFCE's.

Example

Try this: example@example.com.

Troubleshooting

Firefox still won't open GMail

This can be caused by a configuration setting in Firefox. According to [2], this can be fixed by going to the special "web page" about:config, finding network.protocol-handler.app.mailto and setting it to the correct program, in this case /usr/bin/gmail-mailto .

Retrieved from "http://www.gentoo-wiki.info/HOWTO_Open_mailto:_links_in_gmail"

Last modified: Sat, 11 Oct 2008 06:59:00 +0000 Hits: 8,081