Using Google Apps as default mail client in Linux (Gnome)

Ok, pretty simple. I had a couple of machines where I wanted to keep the installation base to a minimum, so WebMail was a natural choice.

I neded to be able to send mails when clicking mail links everywhere in Firefox or other application, so we need to tell Gnome that Firefox is it the default mail client.

So I created the following shell script, which I placed in /usr/local/bin:

#!/bin/bash

DOMAIN=example.com
FIREFOX=/usr/bin/firefox

if [[ "" != "$1" ]]; then
  SEND="?extsrc=mailto&url=$1"
fi

URL=https://mail.google.com/a/${DOMAIN}/${SEND}

if (pidof $FIREFOX); then
  $FIREFOX -remote "openurl($URL, new-tab)"
else
  $FIREFOX $URL
fi

You must replace “example.com” with your own domain.

This script opens a new tab in Firefox, loading Google Apps Mail directly. If Firefox is not yet running, it starts a new instance. If you provide a mailto: URL in the command line, it opens the mail composition section. If no URL is provided, it opens the regular Inbox view.

Now, we must tell Gnome to use this script as the default mail client. Simply open the Preferred Applications dialog in the System/Preferences menu. In the Mail Client section, select Custom and type the name of the script we just created in the Command field, followed by “%s”.

Preferred Applications window

Preferred Applications window

That’s it. It should be working now.

One last warning, tough. If you’re not logged in Google Apps, you will get the username/password dialog, and then you must click the e-mail address link again, in order to send a message.

Edit: you must verify if Firefox is running or not and start a new instance if it’s not. Changed the code accordingly.

1 Response to “Using Google Apps as default mail client in Linux (Gnome)”


  • Aw, this was a really nice post. In concept I want to put in writing like this additionally – taking time and actual effort to make a very good article… but what can I say… I procrastinate alot and under no circumstances appear to get one thing done.

Leave a Reply