How-To Geek

Set Gmail as Default Mail Client in Ubuntu

Every Geek uses Gmail… it’s pretty much required. And now you can set Gmail as the default client in Ubuntu without any extra software. (Windows requires the Gmail notifier be installed)

Just go to System \ Preferences \ Preferred Applications


Under Mail Reader, select Custom, and then put this into the Command window, changing “geek” to your username.

/home/geek/ %s

Next, you’ll need to save this shell script into your user directory ( /home/username ). [Download]

For the curious, here’s the contents of the script:


firefox`echo $1 | sed ‘s/mailto://’`

If you’d like to make the script open a new tab in an existing Firefox window, you can replace the firefox line in the script with the following:

firefox -remote “openurl(`echo $1 | sed ‘s/mailto://’`,new-tab)”

Update: If you want to make the script file hidden by default, you can rename it with a . at the beginning of the file like this: You’ll have to change the path in the preferences, of course.

Open a terminal and type in the following command, to make the script executable:

chmod u+x ~/

Now it should be working.

To test it out… I clicked the contact link on my page… and it immediately opened in Gmail. 

Note that if you aren’t logged into Gmail you’ll be prompted to login to gmail… and you’ll have to click the email link again. Seems like Gmail’s login redirector won’t open the send mail page. But then again… why aren’t you logged into Gmail?

Update: Changed to point to a script so that the mailto: tag would be removed. Thanks VERY much to Mr Linux for not just noticing, but giving me the working script.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 05/10/07

Comments (221)

  1. Henriette

    Using the first command works just fine, although clicking on your contact link gives me the following email address in the to field: “” (without the “”). Any suggestions?
    The second link doesn’t work for me.


  2. Harlem

    Nice hack! I put a link to it on my site!

  3. Mr Linux

    Pretty sweet article! Actually, when I click on the the “Contact the geek” link, I get a new GMail “Compose Mail” page with the To: field set as “”. Any idea why this would be?

    It’s probably possible to strip out the “mailto:” using sed but I’m too lazy to write a regexp right now. :-)

  4. Parker2

    Very nice. Thanks for sharing.

  5. jambarama

    Great tip! This more or less works with any OS–I got it working in Gentoo, with no tweaking of the script (just different menus). Awesome.

  6. evilgold

    this script works for pretty much all linux distros using gnome, not just ubuntu.

  7. Vince

    Is there anyway to do this within Firefox (Windows) itself? Like when I click a mailto link in Firefox it opens in Gmail rather than my email client at work?


  8. Jonathan Hull

    Make sure you have %s at the end of the custom mail command otherwise it won’t pass the email address.

  9. The Geek


    Thanks for noticing the typo! Updated article.

  10. Szestek

    Very useful how-to. Thx for sharing.

  11. kkw211

    Finally! A fruitful and productive use for sed…

  12. brandon

    this is great

  13. Dan

    This doesn’t quite work for Kubuntu (and KDE). Instead, find the equivalent settings page (for Kubuntu – System Settings / Default Applications / Email Client) and enter this:

    /home/geek/ %t

    Note the %t instead of %s. Where /home/geek/ is the same as above. Make sure you remember to chmod u+x ~/

    This will work perfectly for links clicked in KDE applications, but Firefox still needs to be tweaked. Follow these directions:

    But instead of kmail, use the full path to the script (/home/geek/ Enjoy!

  14. Mr Linux


    I suggest you use the GMail Notifier. It will allow you to intercept the mailto: calls on Windows and redirect them to gmail. There’s a bit of flakiness with Vista though because to change the default actions requires user elevation. :-(

  15. The Geek


    Thanks! That’s great stuff. I’ll update the article later with it.

  16. Seamus

    Might I suggest that the script be named so that it is a hidden file. I don’t like anything showing in my home user directory by default other than my data directories (music, photos, documents, torrents, videos, etc.). Simply add a period at the beginning of the script name so that is becomes…

    *Remember to make this change wherever the script is called in the instructions above!

  17. Erik

    I want an identicon

  18. kishan

    Hi there i used this hack i am able to access the gmail only when there is mailto:…… other wise is it looping the compose is not opening ..for example i am browsing craig listing and when i click on the email adress there i am not able to open the compose but it is looping …the gmail pages is just loading thats it can u add or fix this problem ur help will be appreciated

  19. Nick

    I had to replace the ‘ with ” in ubuntu. So my command is:

    firefox “`echo $1 | sed “s/mailto://”`”

    sed complained:
    sed: -e expression #1, char 1: unknown command: `

    when the “s were ‘s

  20. Sam

    Thanks for this incredibly useful tip. I hate client-side mail apps.

  21. michael

    @ Vince, Mr.Linux

    To add default mailto: handler in Windows, look at:

  22. Leigh

    thanks for this – great article.

  23. Rob

    Briliiant stuff thanks!

  24. Paweł Kata (Oszczędzanie pieniędzy)

    This is ABSOLUTELY fantastic! Thank You very much :-)

  25. Seamus

    I get the same looping when I click on a contact link on craigslist as wel. Hmmmmmm…. I wonder what’s going on here?

  26. spevin

    works great. i love this blog. thanks!

  27. Rick King

    At first this script did not work for me, I was getting this:

    sed: -e expression #1, char 1: unknown command: `

    So I took out the ” ‘ ”

    Slight modification:


    firefox “`echo $1 | sed s/mailto://`”

    You can even run the script from the command line: ./

    Nice hack!


  28. Origjigji

    As soon as this option was available (couple of months ago or so), I did it in Firefox and Flock on Windows XP. I really run away from those pop-up emails opening Outlook (opens sooo slow), and I prefere Gmail over it, anyway. (Ever since I started emailing, 10 yrs+, I have rarely used Outlook, but usually read everything right from the server – with all those viruses, etc., such practice saved me more times I can count.)

  29. berlin

    Works great in Mephis. Excellent idea to hide the script via

  30. Dhonn

    You forgot the subject line

    for example: world

    I’m not too good at bash programming but here is my modifications but working with yahoo!

    qs=`echo $1 | sed ‘s/mailto:/To=/’ | sed ‘s/\?subject=/\&Subject=/’`
    firefox “$qs”

  31. Pepe Gonzalez

    To hide the file, you can also make a .hidden file in your home directory and put the files name in there, like this:

    $ touch .hidden
    $ echo “” >> .hidden

    You can add other filenames to the .hidden file (and also directories) separating them with a newline.

  32. geeky

    optimization (without sed):

    firefox “${1/mailto:/}”

  33. Czar

    Great How-To! Now let’s set gmail to the default in Opera. (Yay Opera!)


    # system \ Pref \ Pref App -> ~/bin/gmailto "%s"
    # (IN OPERA) Tools \ Preferences \ Programs \ mailto \ Open with Other App "~/bin/gmailto"
    opera -newpage "`echo $1 | sed "s/mailto://"`"

  34. digitalramble

    Nice tip. Traditionally, such a script would be placed into ~/bin (and the corresponding path name used in the pref box of course).

  35. Atomicron

    Thanks for the very handy instructions. I use Google Apps for my Domain and had to modify the script a little to get it to work. I have posted instructions on my site. (

  36. Anthony

    Worked for me first try……….thanks a bunch!

  37. JDS

    Cutting-and-pasting the script does not quite work for me, and it is almost certainly a character encoding issue.

    Ubuntu 6.06LTS
    Character Encoding for this page detected as UTF-8

    The “single quotes” in the code on this page are not *really* single quotes, they are Unicode right and left single quote marks, ‘ and ’ Take a look at the source code of this page! (see for example)

    I had to chagne everything to the actual straight single quote for the script to work, else sed gave an error:

    sed: -e expression #1, char 1: unknown command: `


  38. tom

    The suggestions for kde are great. They worked perfect except for Firefox, but that was easy too.

    create-> new string /home/geek/

    good to go, and thanks for the script!!

  39. David

    Here’s my script:

    gmailargs=`echo $1 | sed ‘s/mailto:/to=/’ | sed ‘s/\?subject=/\&su=/’ | sed ‘s/\?cc=/\&cc=/’ | sed ‘s/\?bcc=/\&bcc=/’ | sed ‘s/\?body=/\&body=/’`
    /opt/firefox/firefox -remote “openurl($gmailargs, new-tab )”

    I think it covers the entirety of mailto: possibilities. Thank you

  40. Vernon Mauery

    Woa, there David! A few too many seds in a row. Try this one instead.


    #when we are passed an email address like this:
    #we want to generate a uri like this:

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

    firefox “$uri”

  41. dfreer

    Hey, this is awesome thanks!
    Just wondering though, When I use the script, gmail pops up perfectly right in the compose area, but it doesn’t fill in the email address! So basically all the script does is launch gmail. I am using Ubuntu feisty and the script that opens gmail in a new tab in firefox. Could you please help me?

  42. Spike-X

    I’m having the exact same error as dfreer.

  43. Mr Linux

    Are you clicking on a mailto: URI to launch gmail in this way? Or is this something in an application somewhere? For most applications (like Terminal), Gnome will change an email address link into a standard mailto: form (for app compatibility). It’s possible that the script just isn’t able to parse whatever form the particular app you’re using is generating. In that case, it certainly wouldn’t be able to fill in the address.

  44. dfreer

    I try clicking on an html mailto: form, like this one.

    the code looks like this (only with brackets):
    a href=””

  45. dfreer

    here’s my script (note, everything else works fine it just doesn’t put the email address in the gmail form):

    # This script, when set as default mail handler in
    # System > Preferences > Preferred Applications
    # Will use gmail as the mail client!
    firefox -remote “openurl(`echo $1 | sed ‘s/mailto://’`,new-tab)”

  46. JDS

    Hi, again. A simple addition to the script to make it work with Firefox’s “File->Send Link” functionality:

    FIREFOX=`which firefox`
    TO=`echo $1 | sed ‘s/mailto://’`
    ## Next 4 lines let you send link from Firefox
    SENDLINK=`echo $TO | grep ‘body’`
    if [ $SENDLINK ] ; then
    TO=`echo $TO | sed -e ‘s/?/\&/g’`
    $FIREFOX “$TO”

  47. Pete

    Having the same problem as dfreer using Ubuntu feisty and firefox Everything works except email addr does not appear in “To:” line.

  48. Jeff Waugh

    Keep it short and sweet, people. :-)

    FIREFOX=$(which firefox)
    URL=$(echo $1 | sed ‘s#mailto:##;s#?#\&#;s#\&subject=#\&su=#i;’)
    $FIREFOX -remote “openurl($URL)”

  49. Mike

    Same problems as others noting using Firefox and Fiesty, but I come bearing the tasty treat of more info:

    the script (in almost all its variations) works when passed a sample email address in the console, but when you click on a mailto in firefox, the script never seems to get the address. In other words, clicking on a mailto for yields [] in the address bar. The console command [./] yields a result of []

    My best guess is that, in Fiesty, this information is being passed differently than it has been, and the script is no longer picking up the mailto info the way it should. Will update if I manage to create a workaround for this.

  50. Mike

    OK, so…found the solution, and it turned out to be almost painfully simple. In Feisty, you need your command line entry to read as follows:

    /home/geek/ %s

    The %s tells Feisty to pass the mailto link along to the shell script, without it there it doesn’t feed the script any parameters whatsoever, hence the problem.

  51. The Geek


    Thanks for that… typo in the article…

  52. koen

    right mouseclick > send link, doesn’t work :(

  53. dfreer

    Thanks mike, that fixed the problem! it works great now.

  54. Nigel

    For those who are finding the email address is not put in the composition window, there needs to be an escape character in front of the ampersand in the shell script:

    firefox\&tf=0\&to=`echo $1 | sed ‘s/mailto://’`

  55. Dan Waineo


    I use fedora, but I think the instructions are the same regardless. I edited Jeff Waugh’s instructions above for (thanks Jeff!):

    FIREFOX=$(which firefox)
    URL=$(echo $1 | sed ‘s#mailto:##;s#?#\&#;s#\&subject=#\&Subj=#;s#(##;s#)##i;’)
    $FIREFOX -remote “openurl($URL)”

    Note that I stripped the “(” and “)” characters. They were not working for some reason, and are in all of the craigslist listings.
    Also note that the yahoo site address might be different for you in your area.

  56. john kooz

    brilliant, concise, short, and effective. awesome, very helpful. thanks for perpetuating the geekdom! by the way, out of curiosity,in what language is the succinct script written.? thanks

  57. Jonah

    Using Feisty with FF, the first script does not work unless double quotes are added around the URL, like so:

    firefox “`echo $1 | sed ‘s/mailto://’`”

  58. anon

    super-freaking-cool. Thanks.

  59. Thomas

    Any way this command can simply be executed from the Preferred Applications utility, rather than calling a script?

  60. Marcelle

    concise, effective and very easy to use. thanks!

  61. Johan

    Strange, I can’t get it to work properly. In FF I had to create a string named with a value of /home/geek/ %s to make it load from FF. Then I had to escape the ampersand as Nigel suggested, to parse the mail adress. OK, now it works from FF, and as it’s my main browser that’s good.

    But when clicking a mail link in Konqueror, the mail adress is missing… with or without the escape sign in the script.

    I’m trying Gutsy Tribe 4, is that the problem maybe? I noticed there is some problem with the system setting utility writing two $ signs, like $$HOME (it automatically rewrites the full path), sometimes if you edit the path to the script, but as long as you double-check it you’ll be safe from that error.

    Any suggestions?

  62. Alex

    I just did the one by Dhonn (on May 10, 2007 7:42 pm ) and after i removed the quotes it worked perfectly for yahoo!

    Thanks so much man, i really needed this feature!!

  63. Chris

    I’ve adapted the script above by Vernon Mauery so that it works with the “Send Link” in Firefox. I’m sure it could be done with one fewer statements to sed, but I’m too lazy to work it out :) This is with Firefox 2.0.6 on Ubuntu 7.04 by the way.

    Here’s hoping that the form doesn’t do anything screwy to the code below…


    #when we are passed an email address like this:
    #we want to generate a uri like this:

    # The first sed changes ‘subject’ to ‘su’ (gmail uses su instead)
    # The second sed removes the ‘mailto:’ from a standard
    # The third sed is described below
    # When we get something a link from Firefox (others?) that is a “Send Link”, it comes as
    # mailto:?
    # Which we want to turn into
    # &

    #Script adapted from post
    # by Vernon Mauery

    URI=`echo “$1” | sed -e ‘s/subject=/su=/’ -e ‘s/^mailto:\([^&?]\+\)[?&]\?\(.*\)$/\1\&\2/’ -e ‘s/^mailto:[?]\(.*\)$/\&\1/’`

    firefox “$URI”

  64. Johan

    Thanks for the subject fix Chris!

    But none of the suggestions here can make it work from both firefox and konqueror?

  65. tom

    great little hack love it and easy to do.

  66. Jim Robert


    Nice fix… I had a little problem with it

    I had to change,
    URI=`echo “$1″ | sed…

    URI=`echo $1 | sed…

    the quotes messed it up I guess

    I’m running Ubuntu 7.04 Feisty

    Thanks all

  67. pete

    Nice – watch out when copying & pasting these links, sometimes you’ll find double quotes changed to special ‘backwards double’ quotes. Happened to me & sounds like it happened to Jim above.

  68. Paolo

    Thanks to all!
    I think this is the best (based on JDS’s script):

    ARGS=`echo $1 | sed ‘s/mailto://’`
    ## Next 4 lines let you send link from Firefox
    SENDLINK=`echo $ARGS | grep ‘body’`
    if [ $SENDLINK ] ; then
    ARGS=`echo $ARGS | sed -e ‘s/?/\&/g’`
    firefox -remote “openurl($ARGS,new-tab)”

    place it in /usr/local/bin
    you have to create it as root with sudo gedit (or similar)
    then use this command: chmod a+x filepath

  69. l001l

    Nice. works fine. but i want to twist a litle more, so i was thinking about a script that sends a selected archive (with thunar – User Customizable Actions see thunar page for more details) via gmail. tried to use this script and noticed that i could just copy the filepath that apeared in the “to” box. so my question is
    ¿how can i modifiy the script so that it pastes the direction as a attached file or files?

  70. Leif

    If you want it to whatever your default browser is (firefox, konqueror, epiphany, etc) download and install xdg-utils and then replace firefox in the script with xdg-open and it will automatically use your default browser.

  71. kyle

    mine works when i execute the script from a terminal, but when i click a mailto: link, it does not launch firefox.

    any suggestions?

  72. Karel Demeyer


    on gutsy al leats this won’t work this way as the & in the script is interpreted by the shell. Here’s a working version:

    gnome-open\&tf=0\&to=`echo $1 | sed ‘s/mailto://’`

    note that “gnome-open” makes it use your preferred browser instead of hardcoding firefox.


    Karel Demeyer.

  73. fidolip

    is there anything we can’t do w/ ubuntu?:> I love how greatly customizable it is!

  74. Daniel Spiewak

    > is there anything we can’t do w/ ubuntu?

    Get any real work done… :-)

  75. Max

    Thank you very much, that’s what I was looking for, for a very long time.
    double thumbs up

  76. rino

    anyone got this message from gmail: has sent and incorrect or unexpected message. Error Code: -12263

    whatever script is used?

  77. Jeff Carr

    Thank you, this is extremely nice. I saw this (in a round-about fashion) from lifehacker, I hope they update to link your site.

  78. Scott

    Cool stuff.

    Actually, though real geeks access Gmail via IMAP and Mutt :P

  79. les

    I define
    create-> new string /home/geek/

    now if i click mailto from firefox I get the expected behavior (gmail compose);

    however, if i click on an html file in the nautilus, i get the “choose session” dialog for firefox (I have two sessions); does anyone know how I can tell (ubuntu, gnome, nautilus, whomever) that when i click
    on a local html file, simply open it in the current session in a new tab?

    many thanks

  80. Tyler Childerhose

    I guess you can write a script and all that, or just in the custom slot put

    firefox -new-tab

  81. shwetha

    my accuont has been disabled. pls help me to log to dat same id , thank you

  82. Thomas

    Thanks for the script.
    It works fine for simple mailto: links but for others, the page with gmail keeps loading.
    For exmaple, from this page:, I clicked on “J’envoie cet article à un ami” to send the article to a friend. Firefox opens a new tab with Gmail, but nothing is displayed and then page is also switching between “Loading gmail” and “Waiting for Gmail”

    The mailto: link is “mailto:?body=Bonjour,%0D%0A%0D%0AVoici un article int%C3%A9ressant trouv%C3%A9 sur :%0D%0A%0D%0A bonne lecture et %C3%A0 bient%C3%B4t !, votre magazine forme et sant%C3%A9.%0D%0A%0D%0ARecevez chaque semaine la newsletter e-sant%C3%A9 avec ses nombreux articles forme et sant%C3%A9, ses recettes minceur, son test de la semaine et ses forums.%0D%0A%0D%0APour vous abonner gratuitement, cliquez ci-dessous :%0D%0A%0D%0A article d’”

  83. Brian

    This doesn’t seem to be working for me. I get the following “We’re sorry, but your Gmail account is currently experiencing errors. You won’t be able to use your account while these errors last, but don’t worry, your account data and messages are safe. Our engineers are working to resolve this issue. Please try accessing your account again in a few minutes.” Anyone else have this problem. GMail works fine otherwise… just when I use this script I get this error.

  84. Eugene Katz

    Brian, I was getting the same error until I noticed that the second double quote on the line which starts with URI=`echo “$1″ is a smart quote. If you replace it with a normal double quote, it should work fine.

    Then I looked back at the comments and saw that Jim Robert already posted that correction above.

  85. Phil

    I think the new Gmail version broke this script. Now the Compose URL is and I’m not sure how to pass arguments to this format. Any ideas?

  86. Tom Woodbury

    Hi. I really loved this script until it inexplicably stopped working. I guess Gmail changed something (cf. Phil’s 1/16 post). After some time looking around the web, I found “&ui=1” sets the Gmail user interface to the “older” style. So I added that to the script and it now works again. Even though I’m logged into Gmail using the “newer” style interface for regular work.

    New version (works for me – Ubuntu 7.10, Firefox
    firefox “`echo $1 | sed ‘s/mailto://’`”


  87. Felix Benner

    Simple change will try to open tab and if that fails open new firefox:


    if [ “$1″ ]; then
    URL=””`echo $1 | sed -e ‘s/subject=/su=/’ -e ‘s/^mailto:\([^&?]\+\)[?&]\?\(.*\)$/\1\&\2/’`

    if ! firefox -remote “openurl(${URL}, new-tab)”; then
    firefox ${URL}

    # EOF

  88. Billy Charlton

    Looks like Google changed things yet again. This line works for me, as of 30 Jan 2008:

    firefox “”`echo $1|sed -e ‘s/?subject=/\&su=/’ -e ‘s/mailto://’`

  89. max williams

    Fantastic! Thanks.

  90. shiraz

    Really gr8 tip. And it (the main description) works fine for me!


  91. xyz

    This worked for me with opera and slackware 12.0 (had to use %t, not %s in opera preferences for mailto).
    This opens the gmail page in a new tab.


    opera –remote \

  92. mrblah

    Opera in Ubuntu 7.10 Gutsy, the ${} didn’t work for me, so I just replaced it with the backticks version and it now opens a new tab.

    swap in `echo $1 | sed s/mailto://` where ${1/mailto:/} goes looks like this

    opera -remote \
    “openURL(`echo $1 | sed s/mailto://`,new-page)”

    Many thanks to the previous post, I didn’t know about the openURL method


  93. xyz

    To the previous post. How about this: ${f##*:}? (instead of ${1/mailto:/}


    opera –remote \

  94. Andrew Cheong

    We don’t even need a separate file. Simply put this in the custom command field:

    firefox “${%s/mailto:/}”

    This works for me in Ubuntu 7.10, Firefox

  95. Thomas

    @ Andrew Cheong:

    Hi Andrew your solution seems to work fine, when I click on a mailto: link I get a new Gmail composition window in a new tab; but the TO: field contains this “${}” instead of just the email address…. any idea how to correct this?

  96. Andrew Cheong

    [Please ignore my previous comment. I made a mistake. Thanks Thomas!]


    If you have Perl installed, simply copy and paste this into the custom command field!

    perl -e ‘q/%s/=~/^mailto:(.*)$/;`firefox “$1″`;’

    This works for me in Ubuntu 7.10, Firefox, with Perl 5.8.8. I double-checked this time!

  97. mrblah


    your solution producedthe following error message in Opera. Please note I’m using the latest beta so that I can view Youtube in Opera on Ubuntu 7.10 Gutsy, so this may be related or not. For some reason it didn’t transcribe the http link as the openurl is in the URL.

    “You tried to access the address http://openurl(https//….”

    I’ll just say that what I have below works okay for me. YMMV it would appear!! ;)

    opera -remote \
    “openURL(`echo $1 | sed s/mailto://`,new-page)”

  98. mrblah


    scratch that. After testing this no longer works in Opera, neither your nor my version. I still get the openurl lingering in the URL. If you place the script in the system/prefs/preferred apps section however, the script does work in Firefox, in that it opens Opera (my default browser) and goes to the google mail page correctly. But it won’t work in Opera directly.

    I’ll play around with it a bit more

  99. mrblah


    got it. I moved the parameter…to the parameter section *duh*. Switched the %s with %t because the email address was not appearing in the URL causing a gmail 404 error. With %t the email is now added. Now Opera forwards a mailto in gmail without a problem. *whew*.

    tried it again with your non-echo version but it still puts the openurl into the URL. Went back to the script I mashed and it’s fine in both firefox and opera.

  100. xyz

    Sometimes I’d get an error with opera for some addresses (long ones?).
    After fiddling a bit, this fixed the problem:

    ~/gmail/ “%t”

    (put quotes around %t)

  101. bgryderclock

    This is quite handy, thanks!

  102. Andrew Cheong

    ************************* (now supports “?subject=”)

    perl -e ‘q/%s/=~/^mailto:(.*?)(?:\?subject=(.*))?$/;`firefox “$1&su=$2″`;’

  103. morjava

    excellent, i had to change the browser to swiftfox cause thats what i use, but really good stuff just the same

  104. Oilton Graziani Junior

    Thank you very much!!!!!!!!!!!!!

  105. DaveC

    Here’s a version that will handle “Send Link” as well as mailto URLs…..

  106. jason

    this is awesome. thanks a ton, man!

  107. Mor

    this worked fine in gutsy…a bit different in hardy though….i can’t get it to work again

  108. Mor

    sorry bout that, it does work, i just forgot that after the hardy install i have a new username
    all is good

  109. xavier


  110. ubuntu7.10

    not working. yes you can open up gmail but not an email, nor a subject or body. Gmail hangs. Also sometimes the %s doesn’t seem to run.

    ubuntu 7.10 gutsy

    tried the perls script and others, can only open gmail.

    nice idea, clearly it works for some of you. Just not for me for now.

  111. ubuntu7.10

    scratch that.

    ran DaveC’s perl line directly in the Custom line and it works, adds email, also adds subject line and body.

    nice job

  112. Garoth

    Thanks a lot!

  113. kindofabuzz

    This worked great when i was on FF# beta 5. Once FF3 final came out i had to change network.protocol-handler.external.mailto to true in about:config for it to work.

  114. Andrew

    This works for both mailto links and sending regular URL’s with gmail. Copy and paste this directly into the Mail “custom” field of “Preferred Applications”.

    perl -MURI::Escape -e ‘$to= shift; if ($to =~ /^([^\?]+)\?(.*)$/){$to=$1;$args=”&”.$2;$args=~s/\&subject=/&su=/};$to =~ s/^mailto://i; exec(“firefox”,””.URI::Escape::uri_escape($to).$args);’ ‘%s’

    Credits –

  115. Venkatesh

    Thanks a lot!!
    The javascript given in Gmail’s blog didn’t work for me. ( I use Iceweasel in Debian )

    But both The Geek’s script and DaveC’s script works fine!
    Great job :)

  116. AJ

    For Opera 9.5x the following works:

    opera –remote “openURL(`echo $1 | sed ‘s/mailto://’`,new-tab)”

    This line is basically the same as the firefox line except that :
    1. There are two hyphens before ‘remote’
    2. openurl needs to be replaced with openURL

  117. Emre

    Good job, Dave C.! I still don’t really understand all these linux commands and stuff, so thankfully somebody had the simple instructions.

  118. Jesse

    Andrew’s Comment on June 28 works great for me–the others wouldn’t work or would not work with “subject” line :-(.

    Firefox 3.0.1
    Ubuntu 8.04.1

  119. Stephen

    it’s simpler and just as (more?) effective to let gmail handle the mailto: URL.
    Just put the following in the preference box:

  120. Amanda

    Works fine when I want to email links from Firefox but I’m not given the option to use anything other than Evolution and Thunderbird if I want to send a saved file from my machine. Any tips?

  121. Guyon

    This worked perfectly, thank you VERY much!

  122. rolandog

    Hi. Great tutorial. I noticed that the chmod path needs to be pointed to the correct location of the script. In your case, ~/geek/

  123. Jim Ignatwoski

    Arguably, you should be placing your personal executables in /home/geek/bin. Then hide the bin folder if you want. bin is automatically added to your PATH variable if it exists (this occurs in your ~/.profile script). That way you can run the commands from a terminal without specifying the full path to the executable.

  124. Nat

    I’m using Firefox3 on Ubuntu Hardy and keep getting stuck in a redirect loop when using the provided script. Here’s my workaround: you need a &fs=1 in the URL like so:

    firefox -remote “openurl(`echo $1 | sed ‘s/mailto://’`,new-tab)”

  125. Rich

    It opens a new tab and opens a blank compose email page, but it doesn’t put address in the to field. Any ideas?

    I took Nat’s line above because I have Firefox3.0.1 on Hardy also.

  126. Thomas

    Ok, two things, using Ubuntu 8.04 and Firefox 3 the above explanation opens gmail, in a new tab ( ?? i DID NOT modify your file though??) into the compose mail. So all in all, it works fine…

  127. Rich

    But it doesn’t fill-in the to address. I have to go back to the orig. tab(where I clicked on the contact, or whatever it was) and copy and past the email address if I can see it or look at the preview bar at the bottom of firefox to see if that shows the actual address.

    Is there any way to get it to populate the to: address?

  128. Matias Sulzberger


    I don’t know why but it doesn’t work with Gnome-Do, which was the main reason I made this tweak.

  129. Sonja

    I get an error “Redirect Loop: Firefox has detected that the server is redirecting the request for this address in a way that will never complete.” :(

  130. Lightbreeze

    I modified your script together with another to make this work in Mozilla Prism.
    See my post here for the script.

  131. Lightbreeze

    … it also handles the subject and body and someone ever wants to scrump that.

  132. Kurra

    Thanks DaveC, that worked perfect!

  133. zeddock

    I just can’t get this to work.
    Ubuntu 8.04 64 bit
    Firefox 3

    Even uninstalled and reinstallled Firefox.
    Any help for me?



  134. PabloC

    In firefox 3.0.3 (and earlier?) under Ubuntu 8.04 you can select Gmail directly as the preferred email application and then all this is done in the background.

  135. Scott

    You don’t actually have to create a full script. Just pass the firefox line to bash using the -c option.

    In other words, instead of pasting “/home/geek/ %s” into the Preferred Applications panel, paste the following:

    bash -c ‘firefox -remote “openurl(`echo %s | sed ‘s/mailto://’`,new-tab)”‘

    No script needed. Works for me, anyway.

  136. Emiliano

    @Scott: “No script needed. Works for me, anyway. ”

    I was trying to do the same thing, but well you came up with the code faster.
    Thanks :)

  137. Soonlar

    This worked for me on Craigslist with Firefox 3.0.3 with Ubuntu 8.04 (hardy) as of Nov 11th 2008.

    (as referenced from Billy Charlton)

    firefox “”`echo $1|sed -e ‘s/?subject=/\&su=/’ -e ‘s/mailto://’`

  138. Free Gamer

    I don’t get it……

    Why not just put the following in the custom command:

    firefox –remote “openurl(,new-tab)”

    No need to use a script file or sed.

  139. frazer

    Hey, thanks, this is great.

    It doesnt quite work if the mailto link also has ?subject=make+me+better&body=heres+how

    you just get an ugly looking email address, so I wrote this to make it work

    hope you like it, and give it to every one

    sorry my scripting is a little amatuerish. if any one has a better way to do it, let me know


    TO=`echo $1 | sed ‘s/mailto:\([^?]*\).*/\1/’`
    SU=`echo $1 | sed ‘s/.*subject=\([^&]*\).*/\&su=\1/’`
    SU=`echo $SU | sed ‘s/mailto:.*//’` #this is to get rid of the subject if nothing matched
    CC=`echo $1 | sed ‘s/.*cc=\([^&]*\).*/\&cc=\1/’`
    CC=`echo $CC | sed ‘s/mailto:.*//’`
    BCC=`echo $1 | sed ‘s/.*bcc=\([^&]*\).*/\&bcc=\1/’`
    BCC=`echo $BCC | sed ‘s/mailto:.*//’`
    BODY=`echo $1 | sed ‘s/.*body=\([^&]*\).*/\&body=\1/’`
    BODY=`echo $BODY | sed ‘s/mailto:.*//’`

    firefox “$TO$SU$CC$BCC$BODY”

    #firefox -remote “openurl($TO$SU$CC$BCC$BODY,new-tab)”


    it works with all the possible mailto; extras.
    thanks again.

  140. frazer

    oh, I just saw


    firefox “”`echo $1|sed -e ‘s/?subject=/\&su=/’ -e ‘s/mailto://’`

    thats much better than what I wrote

  141. zeddock

    This is the only one that works for me on FF3 and Ubuntu 8.10.
    firefox remote “openurl(,new-tab)”

    Note that to use a script, which this entry is not, I had to put “sh ” in front of the entry for the prefered mail custom entry.


  142. Socrates


    Great Geeking!

  143. bill

    I now use Mozilla Prism — after installing Gmail as an app, I set my preferred email as “prism-google-mail”. Pretty slick.

  144. deuts

    great! great! great!

    Now I can enjoy gmail more fruitfully and in linux.

    thanks for this tutorial

  145. Ron

    this is the best solution I’ve found:

  146. vince
  147. Don

    This is completely redundant if you use Mozilla Firefox.

    Just go to Edit > Preferences > Applications and scroll down until you see the ‘mailto’ option.

    Select ‘GMail’.

    Presto, done.

  148. Don

    Oh I forgot the icing on the cake….

    In System > Preferences >Preferred Applications set your Mail Reader to ‘Custom’….

    with the command ‘firefox %s’

    Presto, done. Now anywhere in Ubuntu/Gnome you click a email link it will open in GMail.

  149. Domingo

    Very nice; great.

  150. zeddock

    I have never been able to get this or others to work. Evolution always tries to launch when I am outside of firefox.

  151. calebk

    Thanks, worked great for me!

  152. mns

    Just a little hint,

    if you want to have your full gmail page you need to change the code

    firefox -remote “openurl(`echo $1 | sed ‘s/mailto://’`,new-tab)”

    have fun

  153. Scott

    Anyone know if there’s a url param that will let you add an attachment?

    I’d like to make the “Send To” right-click work. It makes zip/ in a tmp dir so something like
    “view=cm&fs=1&to=…&attach=/tmp/” (except that’s not it…)

  154. Joe

    Seems a lot easier just to set up evolution to get you mail from gmail, maybe thats just me

  155. Norio

    @Don, thanks! Works very well if you just use the built-in Firefox feature!

    A note to others reading this and trying it: The firefox solution doesn’t seem to work if you’re using Gmail in offline mode / unstable connection mode. Loads about 95% and then just stops.

  156. magnoliasouth

    Well this didn’t work for me. I even followed Don’s suggestion, but still nothing. :(

    I’d love to get this to work though.

  157. M 先生

    hello all,

    for ubuntu user with the prism-google-mail apps,


    `echo “prism -uri“$1 | sed ‘s/mailto://’`

    enjoy :)

  158. magnoliasouth

    I suppose I should mention that everything listed says what it should say. In Firefox my preferred app is Gmail, in System > Preferences > Preferred applications everything is set properly AND it does remember it.

    Yet, whenever I click on a mail link anywhere… and I mean anywhere… absolutely nothing happens. My screen blinks as if to tell me, “Yeah, I got that this is what you want to do, okay? But haven’t you figured out it isn’t going to freaking work???”

    It’s really an annoyance. In fact, there are quite a few Ubuntu annoyances that bother me so much that I’m tempted to buy a version of Windows online. This was a completely clean install with hardly anything on it. However extremely simple, yet seriously important, things just do not work like headphones, flash, help files and probably more that I just don’t know about.

    It’s not that I didn’t seek help, because I did. I sought help here, but there wasn’t any. I’ve sought help from the Ubuntu forums, but still no fixes. > Statistics > Find all threads started

    Sure, Ubuntu might have it’s pros, but the cons are beginning to outweigh the pros. When you can’t even problem solve by looking in the help files because even the help files do not work, then you have an issue.

  159. konsumer

    Nowadays, in firefox (3.0) you can set handler to gmail in preferences, in firefox. that means, just set your system handler to “firefox %s” rather then a script. it’s a more complete solution.

  160. Javier

    konsumer’s solution works for me ;)

    If someone knows the answer for Scott’s question please share with us…

  161. Carpintonto

    The down-loadable script works perfectly on

    Linux Mint 7 Gloria – Main Edition \n \l
    2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 19:49:51 UTC 2009 i686 GNU/Linux


    Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20090716 Linux Mint/7 (Gloria) Shiretoko/3.5.1

    1. Download the script, do not copy and paste from this page, and chmod as instructed.
    2. In ff Shiretoko/3.5.1 Edit, Preferences, mailto select Use Gmail
    3. In ff open a new tab for about:config
    4. filter for “network.protocol-handler.external.mailto” (without quotes)
    5. right-click the entry and toggle to true.

    It will open in a new tab if ff is already open.

    Great hack !!
    sed doesn’t stumble if there is no “mailto:” in the param

    thanks :-)

  162. Carpintonto

    If you are using a window manager whose menu doesn’t work like gnome, the command to load the preferred applications utility is

  163. hmm

    Shouldn’t there be a program that does this?

  164. Diego Lima


    I improved a bit the script to support multiple ways of opening gmail (firefox new window, firefox tab, opera). Here is my modified version:


    #Get our variables from stdin

    #See how we want to open gmail
    case $OPENIN in
    “ffwindow”)CMD=”firefox`echo ${EMAIL} | sed ‘s/mailto://’`”;;
    “fftab”)CMD=”firefox -remote openurl(`echo ${EMAIL} | sed ‘s/mailto://’`,new-tab)”;;
    “opera”)CMD=”opera`echo ${EMAIL} | sed ‘s/mailto://’`”;;

    #Run command

  165. smaddox

    I combined the best 2 scripts to get the following script that opens any mailto: in a new tab. Just edit preferences to (ignoring the ‘s), and save the following scipt to /home/[user]/
    uri=`echo “$1” | sed -e ‘s/subject=/su=/’ -e ‘s/^mailto:\([^&?]\+\)[?&]\?\(.*\)$/\1\&\2/’`
    firefox -remote “openurl($uri,new-tab)”

    Note: be sure to check that the quotations aren’t fudged. When copying from the website to gedit all the quotation marks were changed to some weird unicode ones that don’t function properly.

  166. Marius marais



    for GMail, and


    for Google Apps mail in the “Command” field will automatically open the default browser and allow Google to parse the mailto link, making things like ?subject=hello!& also work correctly. As a bonus, it also works if you aren’t yet logged in.

  167. Jesse

    Geek: This is a unnecessarily complicated solution. Simpler solutions in comments above.

  168. easoukenka

    This works so that if you click something that does not have a mailto but just opening your browser “aka mail-notifier” it will just open gmail. This is customized for chromium.

    Thank you so much for this!

    if [ “$1” = “” ]; then
    /usr/bin/chromium-browser –app=
    /usr/bin/chromium-browser –app=”`echo $1 | sed ‘s/mailto://’`”

  169. bradley

    Much simpler solution:
    Choose Gmail as the mailto handler in your Firefox Preferences (default option in 9.10 NBR), then set Firefox to be the Ubuntu mail handler (that is, choose Custom and point it to “firefox %s”). Since Firefox is configured to handle mailto: addresses correctly you no longer need a script to do anything messy, plus Firefox can now handle mailto: links on webpages internally without having to call an external script.

    To set up Google Apps to work, do these steps —
    Go to about:config and toggle this:

    Type this into the address bar and hit enter:

    Then do the same thing as mentioned above.

  170. konsumer

    bradley: I said that above.

    I started using chromium, and this solution will work for whatever you set as your default browser:


  171. Mark B

    In spite of all the comments and hacky scripts posted here, konsumer’s post above is the best solution and probably the simplest. I’d suggest to use xdg-open instead of gnome-open to keep it more general (xdg-open calls gnome-open on a gnome system anyhow). So the command is:


    Add a “a/ before the question mark if you are a google apps user.

  172. Mark B

    I should add to my comment above that I could only get xdg-open or gnome-open to work properly if I put the command in a small script and called that from gnome’s preferred applications. E.g. set custom mail reader to:

    /home/markb/bin/open-mailto %s

    That file contains a single line:

    exec xdg-open “$1”

  173. Mark B

    You should be able to enter that xdg-open or gnome-open line directly in the gnome preferred applications custom line. I have worked out why it doesn’t work however. It is due to a bug in gnome where it always prepends a bogus space when it substitutes the %s (i.e. it does not strip/trim the string). This is at least the case on my up-to-date ubuntu 9.10 karmic installation. So you can’t avoid the command getting 2 url args instead of one.

    So we will have to use a 3rd party script as I describe above until gnome/ubuntu fix this silly bug.

  174. anon

    Pray tell, where is “System \ Preferences \ Preferred Applications”?
    WHY can people (in general) not also hint the commandline program name? There is *a heck of a lot* done for l10n and i18n, and posts like this torpedoe it all.. :(

  175. JDT

    Has anyone ever gotten this to work with Gnome Do’s Gmail Contacts plugin? I’ve tried every solution proposed on this page and nothing works. Maybe it’s a bug in the plugin.

  176. JDT

    OK, I got it to work in Gnome Do:

    ’email’ TAB ‘name of your contact’ ENTER …or the other way around

    I was selecting the contact, then selecting the email address, then hitting ENTER, which made sense to me, but that’s not how it works.

  177. Denise

    @Mark B
    The bug you mention can be overcome by adding another % character.

    See this post on the Fedora Forums for background >

    So using the following works without having to create a script >


  178. Dave Espionage

    Here’s a way to do it for Google Chrome, now that they have a version that (mostly) runs on Ubuntu, it pops up in a nice little app window outside of the browser, so you can send and make it vanish afterwards. Of course all the proposed tweaks and simplifications for firefox don’t seem to work for chrome, that would be too easy.

    The script modifications:

    /opt/google/chrome/google-chrome –app=”`echo $1 | sed ‘s/mailto://’`”

  179. cas

    I have had the same issue with chrome beta (ubuntu 9.10)
    This script doesn’t work properly

    Somebody know how works?

    Is this correct?
    1. create a file with:

    /opt/google/chrome/google-chrome –app=”`echo $1 | sed ’s/mailto://’`”

    2. cmod u+rx /opt/google/chrome/

    3. change command on preferences:

    /opt/google/chrome/ %s



  180. Marius Marais


    You don’t need the script if you use the proper URL. Just put

    /opt/google/chrome/google-chrome -app=

    in the “Command” field and you’ll be good to go.

  181. Marius Marais


    You should really revisit some of your articles :) They’re very popular and easy to find with Google, but without some TLC a lot of the value gets lost.

  182. cas


    this part makes all diference in the command:

    “…………………………?extsrc=mailto&url=%s ”

    Now works:

    /opt/google/chrome/google-chrome -app=

  183. Sam Gardner

    Change firefox for chrome in the script, and it works (kind of) for chrome

  184. martin

    Thanx!! Works way cool with Karmic/Chromium without changing anything. I love the script opens a new tab by default and close it after sending the email or discarding it.


  185. treschny

    Marius – your suggestion worked where nothing else above did. No email address gets copied to the To: field though…anyway to add that in?

  186. Noel

    Sorry, scratch that. Seemed to be working but now looks like it isn’t.

  187. martosurf

    Thanks to the guy how gave us the link to the perl script, adding that single line to the mailto: in System->Preferences works like charm with Google Chrome and Kubuntu.

    Just remember to change [ugly] “firefox” with Chrome’s working dir AND the final %s for a %t (%s is for GNOME, %t for KDE)

  188. Kristian Erik Hermansen

    A better version of the script I crafted that works is given below. The other ones above are outdated it seems. Just call the script the same name and pass parameters as normal in Ubuntu’s Preferred Applications configuration…


    google-chrome –app=”$(echo “${1}” | sed ‘s/mailto://’)”

  189. Kevin

    Why invoke the unnecessary sed command? Simple regex replace is built into bash. Use ${1/mailto:\/\//}.

  190. Jack H.

    Hey, Kevin – would you mind posting the entire script that you find to be working? I inserted your “suggestion” into Kristian’s most recent code, and it didn’t work. :-/


  191. Joseph

    There is a much better way… very easy in fact. check out

    The one thing they leave out is that when you are in the “gconf-editor” you are going to add a new key.
    (kinda like adding a registry key in windows)
    the key “name” is “appsdomain” (without the quotes) and the value type is “string” and in the value box you enteryourdomain. ie. “” (without the quotes)

  192. Jonathan Matthews

    Jack – I going to assume you swapped Kevin’s code in for the single “$1” in the original, which won’t work. What he means you to do is:

    firefox “${1/mailto:/}”

    This also has the nice effect of removing the backticks, which are a bashism and won’t work with some other shells.

  193. King

    The single quotes and double quotes messed me up when I copy and paste: be very sure to replace them with the single and double quotes from your keyboard. Blasted unicode…

    And I made a little change to handle the ampersand nicely too.

    firefox “`echo $1 | sed ‘s/mailto://;s/?/\&/;s/\&subject=/\&su=/;s/%26amp%3B/%26/i;’`”

  194. gameplace123

    I made a couple of changes to the apostrophes, they messed up the original script. I also put a notification in there (note you must have notify-send installed).

    sudo apt-get install libnotify-bin

    notify-send –icon=email ‘Sending email to’ `echo $1 | sed -e ‘s,%40,@,’ | sed -e ‘s,mailto:,,’`
    /opt/google/chrome/google-chrome –app=””`echo $1 | sed -e ‘s,%40,@,’ | sed -e ‘s,mailto:,,’`

  195. kris

    In order to be able to open a mailto link within programs like evince, you can add the line

    /home// Ux,

    to “/etc/apparmor.d/abstractions/ubuntu-browsers” (don’t forget to restart the daemon with “/etc/init.d/apparmor restart”)

    Oh yeah, cheers!

  196. smws

    I just wanted to say that with Google Chrome 5.0.342.9 beta under Ubuntu, I did everything *exactly as stated in the post*, using the first script, simply replacing “firefox” with “chrome”, thus:


    chrome “`echo $1 | sed ‘s/mailto://’`”

    It worked great! Opens in a new tab for me, which I like, but that might be some personal setting or other.

  197. tonk

    Hey, it’s much easier to use gmail as standard in Ubuntu. All you have to do is (1) set googlemail as standard mail program in Firefox (you can do so in Firefox’s settings) and (2) write /usr/bin/firefox “%s” as “custom” option in the Ubuntu dialogue for preferred mail application. –

  198. creativeboulder

    So I have been using Google Chrome and the “app=” parameter. Basically, when I copied the code from above I had to change the ’s/mailto://’ to `s/mailto://`. Then I added –app= in front of the quotes. Plus, I am using a Google App account. Works great though.

    google-chrome –app=”`echo $1 | sed ‘s/mailto://’`”

  199. Kerem Basaran


    Your solution is very fast and easy. I couldn’t manage to do it with given script above. Firefox has an option for how to handle mailto links in its preferences and gmail is already in there. I only wish it popped out a separate window or tab but it works fine the way it is and seems pretty reliable.

  200. armenak

    Merci pour ce script impeccable!

  201. kodiak

    Firefox’s build-in mailto preference (Preferences > Applications, scroll to ‘mailto’, choose ‘gmail’ from drop-down et voila) works perfectly and opens in new tab if you choose ‘open in a new tab’ in Preference > Tabs)

  202. Nathan Belomy

    Thanks. Works awesome with ubuntu alt 10.04

  203. Vítor Ferreira

    Since Firefox already includes an option for using Gmail as predefined mailto handler and therefore default email client, I figured out the link used in that option and modified the script to the following.


    firefox “`echo $1`”

    It works and the above link is translated into one similar to the posted here. However, i find it more legible.
    BTW, with both addresses, you no longer need sed, just echo. Don’t know why.

  204. QL Studio

    How about this?


    notify-send “Opening Gmail” “`echo $1`” -i /usr/local/share/icons/hicolor/48×48/apps/google-chrome.png -t 5000
    google-chrome -app=”`echo $1`”

    opens small app window using google chrome and notifies with a nice icons too!

    be nice to get a regex to extract just the email address to use in the notification – anyone?

  205. ActionParsnip

    You don’t need the .sh extension in Linux. File extensions don’t mean very much at all in Linux.It’s handy to have if you do a LOT of scripting in a LOT of languages but it’s not needed to make the command run. In fact MOST of the commands in the OS are scripts but people run them as binaries, they don’t have the file extension either.
    Nice script though. You could also script the installation and change the user config ;)

  206. Trey Brister

    Here is a smail hack to make it work with your default browser in Gnome or Ubuntu.

    Also it works on command line with up to 9 comma separated email addresses

    I put in my path and named it mailto



    if test -z “$1”
    gnome-open “`echo $GMAIL; echo $1 | sed ‘s/mailto://’`”&
    gnome-open “`echo $GMAIL$1 $2 $3 $4 $5 $6 $7 $8 $9`”&

  207. mind-v

    My modification that working for me:

    chromium-browser `echo `$GMAIL`echo $1|sed s/mailto://`

  208. leopoldo

    hey guys, i tried
    /opt/google/chrome/google-chrome -app=

    Chrome, Linux Ubuntu 10.4 and it works fine, it opens a new window and everything… but it doesn’t copy the email address in the ‘to’ field
    any suggestions?

  209. leopoldo

    it works! never mind my previous question.
    i changed it back and forth a few times and now it copies the address… i have also tried on a differente mailto address, that might have also been the issue.
    but who cares?! jaajaj at least it worked |O_o|

  210. Jon

    worked – just changed firefox to nickel-browser. THANKSSSSSS

    jolicloud 1.2

  211. Dave

    For those of you looking to set Google Apps as the default mailto: client, I thought I’d pass on the solution I eventually got to work. Follow the how-to Geek’s steps above, but replace the bash script with the following script:

    # Open new window in Google Chrome when “mailto” is clicked in FireFox, or any other app
    # in Ubuntu for Google Apps domain name users.

    # Enter your google apps domain name below, without the “www”


    echo $URL_COMPLETE

    if test -z “$1”
    then /opt/google/chrome/google-chrome –new-window “`echo $URL_COMPLETE; echo $1 | sed ‘s/mailto://’`”&
    else /opt/google/chrome/google-chrome –new-window “`echo $URL_COMPLETE $1 $2 $3 $4 $5 $6 $7 $8 $9`”&


    Notice you need to replace the text “” with your Google Apps domain. Do not include
    the www, do surround the domain with quotes.

    Prerequisite: Google Chrome must be installed before running the script.
    Here is a good site to test it:

  212. Chelle

    Just figured out a way to do this using Google Chrome’s built in Application Shortcuts feature.

    1) Load gmail in a Chrome window
    2) click on the Chrome configuration wrench in the right corner of the browser window
    a)scroll down to Tools
    b) click on create application shortcuts
    3) create shortcut on the Desktop
    4) right click the Gmail logo that is now on your desktop
    a) click on Properties
    b) copy the line in the Command field
    5) in your panel go to System->Preferences->Preferred Applications
    a) paste the line you copied from gmail properties in the Command field under Mail Reader

    Now you can have Gmail load in its own window by using the logo on your desktop plus whenever you click a mailto link on the web a new Gmail Compose window will pop up. Enjoy!. I know it looks long but it only takes about a minute to do :)

  213. Frank Cox

    I am using the script in Linux Mint 10.10 DVD edition and it opens Gmail instead of a compose message window as the script I used in 9.4. it is not supposed to?

  214. Rick Magers


    I use LinuxMint LXDE and Gmail Apps and this works for me:


    xdg-open “`echo $1 | sed -e “s/?subject=/\&su=/” -e “s/mailto://”`”

  215. Errol Dennis

    The simplest way I find is to:
    1) Download “Desktop Webmail” from Ubuntu Software Center.
    2) Start it from the “Application | Internet | Desktop Webmail” Ubuntu menu and select Gmail.
    3) Under the “System | Preferences | Preferred Application” ubuntu menu, select “Desktop Webmail” as the Mail Reader.

    You are now good to go.

    Remember to configure your default web browser to the desired one and let the browser remember your GMail password.

    Also, if you uncheck the “Ask again” checkbox on “Desktop Webmail” you can only undo this change by setting “remember=false” in the “~/.config/desktop-webmail.ini” file.

  216. Roland B.

    I’m using Google Chrome with Send from Gmail (by Google) extension( ). I like that better then script method.

    I suggest it for Chrome users.

  217. Jake

    I just changed the preference for the mailto protocol in Firefox (in the “Applications” tab in the preferences window) to “Use GMail”. Then, I just have a small shell script that I set as the default mail client:

    firefox -remote “openurl($1)”

    This way, I don’t have to worry about parsing the subject, body, cc, bcc, etc.

  218. Francesco

    Here my version for chromium

    chromium-browser `echo `$GMAIL`echo $1| sed ‘s/mailto://’`

  219. Francesco

    sorry, but this page insert wrong char separator:

    here the corrected one:

    chromium-browser `echo `$GMAIL`echo $1| sed “s/mailto://”`

  220. Francesco

    nop… still mix up ” and ‘, sorry: cannot paste it

  221. Vlad

    It’s easier to just [sudo apt-get install gnome-gmail] and then set that as the preferred email application.

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!