Making FastMail default mail reader in GNOME

In Ubuntu, I am using mail-notification to get notified about new e-mail in my FastMail account. From time to time I also click on some mailto link. In both of these cases I would like a FastMail page to be opened in Opera. But to make it a lil bit smart, I would like to open inbox when double-clicking on new e-mail notification, but in case I click mailto link I would like to be redirected to compose new FastMail e-mail url.
I have created a bash script, which does this job quite well. All you need to do is to copy the following text into clipboard, past it into some text editor and save it into /usr/bin/fastmail-mailto.sh.

#!/bin/sh
BROWSER="opera"

# Mailto URI may look like this
#mailto:foo@bar.com?subject=hi&body=message

# Most of the parameters are called the same, we just need to parse e-mail
uri=`echo "$1" | sed -e 's/^mailto:/*([^&?]+)[?&]?(.*)$/1&2/'`

if [ "$uri" ];
then exec $BROWSER "http://www.fastmail.fm/action/compose/?to=$uri"
fi

exec $BROWSER "http://www.fastmail.fm/"

After you are finished, you need to make the file executable by calling the following command: sudo chmod a+x /usr/bin/fastmail-mailto.sh.
Finally just go to Preferences > Preferred Applications and change Mail Reader to Custom with the following text: /usr/bin/fastmail-mailto.sh.

Leave a Reply

Your email address will not be published. Required fields are marked *