I have recently starting using google’s chrome browser on my Fedora 14 box and I love it. The browser leaves plenty of real estate for websites, it’s super fast and I love to be able to sync my bookmarks (although I have been doing this in firefox for a couple years with the help of addons).
I will move on since this isn’t a browser review. The one annoying thing I found was I could not set gmail as my default mail client which really sucked when clicking on mailto links on websites like craigslist for example.
Below is how I worked around this problem in just a few simple steps.
NOTE: This should work on ANY linux distro, I have tried it on Ubuntu and Fedora, but I will being using Fedora for the following screenshots.
First we need to know where chrome is installed.
$ which google-chrome
/usr/bin/google-chrome
In our example the Chrome binary lives at “/usr/bin/google-chrome”.
Now we want to open our favorite text editor (vi, nano, gedit, whatever) and create a text file with the following contents. Replace /path/to/chrome with the path identified above.
#!/bin/bash
ADDRESS=`echo $1 | sed 's/mailto://'`
/path/to/chrome "https://mail.google.com/mail?view=cm&tf=0&to=$ADDRESS"
Save the above in your home directory as .mailto.sh (example /home/username/.mailto.sh)
Replace username with your username!
The dot in front of the name makes it a hidden file, this just keeps your home directory tidy. You can feel free to name the file anything you like.Now we have to make the above script executable. Open a terminal and enter the following commands…
First let’s make sure you are in your home directory, run the following command:
cd ~
Now let’s set the file as executable with the chmod command:
chmod u+x .mailto.sh
Now the last step is to tell linux to use this as your default mail app. Click System > Preferences > Preferred Applications. Under mail reader set the drop down to custom, and enter the path to the script file we just created.
That’s it, now when you click an email link in the browser it will open a compose email screen with the address in the TO field.Go ahead and try it, click HERE.
You may be prompt to log into GMail if your are not currently logged in.
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
8 Comments
Join Our Newsletter
Categories
- Bash Scripting (17)
- Basic Commands (51)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (65)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
The preferred applications dialog does not provide the 'Custom' choice in Ubuntu 11.04.
Neither does it in Fedora 15
It's now in
System Settings -> System Info -> Default Applications
Same problem here (except I'm running 12.04.)
Is there any way around this? Perhaps editing a registry file or something to add "mailto_script.sh" as an email program?
you are the best!
Thanks very much for this great tip!
Thank you very much! 🙂
Works with chromium too
I have been trying to do this in Mint 21.2 Cinnamon, so that clicking on a mailto link on a web page brings up Gmail's Compose window. However, in this version the writers of Mint have deliberately made it hard not to use Thunderbird as the default email application.
I made the .mailto.sh file according to your instructions. When you view hidden files in the Home directory and run the file, it does indeed open a Gmail Compose window.
Then, as per instructions, I entered the two lines in Terminal
cd ~
chmod u+x .mailto.sh
But in Mint 21.2's Preferred Applications list there is no way of selecting a custom path so that I can link to .mailto.sh. There is a path called 'Autorun Prompt', but this does nothing and the default email application is still Thunderbird.
Is there some way of setting a 'custom' line to .mailto.sh, maybe by using Terminal commands?
Many thanks in advance for any suggestions.