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/open_mailto.sh %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:
#!/bin/sh
firefox https://mail.google.com/mail?view=cm&tf=0&to=`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(https://mail.google.com/mail?view=cm&tf=0&to=`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: .open_mailto.sh. 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 ~/open_mailto.sh
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.


Using the first command works just fine, although clicking on your contact link gives me the following email address in the to field: "mailto:geek@howtogeek.com" (without the ""). Any suggestions?
The second link doesn't work for me.
-Henriette
Nice hack! I put a link to it on my site!
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 "mailto:geek@howtogeek.com". 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.
Very nice. Thanks for sharing.
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.
this script works for pretty much all linux distros using gnome, not just ubuntu.
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?
Vince
Make sure you have %s at the end of the custom mail command otherwise it won't pass the email address.
Jonathan,
Thanks for noticing the typo! Updated article.
Very useful how-to. Thx for sharing.
Finally! A fruitful and productive use for sed…
this is great
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/open_mailto.sh %t
Note the %t instead of %s. Where /home/geek/open_mailto.sh is the same as above. Make sure you remember to chmod u+x ~/open_mailto.sh
This will work perfectly for links clicked in KDE applications, but Firefox still needs to be tweaked. Follow these directions:
http://gentoo-wiki.com/HOWTO_I.....ent:_KMail
But instead of kmail, use the full path to the script (/home/geek/open_mailto.sh). Enjoy!
@Vince
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.
@Dan,
Thanks! That's great stuff. I'll update the article later with it.
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…
.open_mailto.sh
*Remember to make this change wherever the script is called in the instructions above!
I want an identicon
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
I had to replace the ' with " in ubuntu. So my command is:
#!/bin/sh
firefox "https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed "s/mailto://"`"
sed complained:
sed: -e expression #1, char 1: unknown command: `
when the "s were 's
Thanks for this incredibly useful tip. I hate client-side mail apps.
@ Vince, Mr.Linux
To add default mailto: handler in Windows, look at:
http://msdn2.microsoft.com/en-.....53633.aspx
thanks for this - great article.
Briliiant stuff thanks!
This is ABSOLUTELY fantastic! Thank You very much
I get the same looping when I click on a contact link on craigslist as wel. Hmmmmmm…. I wonder what's going on here?
works great. i love this blog. thanks!
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:
#!/bin/sh
firefox "https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed s/mailto://`"
You can even run the script from the command line: ./open_mailto.sh someone@email.com
Nice hack!
~~RK
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.)
Works great in Mephis. Excellent idea to hide the script via .open_mailto.sh
You forgot the subject line
for example:
mailto:you@host.com?subject=Hello world
I'm not too good at bash programming but here is my modifications but working with yahoo!
#!/bin/sh
qs=`echo $1 | sed 's/mailto:/To=/' | sed 's/\?subject=/\&Subject=/'`
firefox "http://compose.mail.yahoo.com/?$qs"
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 "open_mailto.sh" >> .hidden
You can add other filenames to the .hidden file (and also directories) separating them with a newline.
optimization (without sed):
#!/bin/sh
firefox "https://mail.google.com/mail?view=cm&tf=0&to=${1/mailto:/}"
Great How-To! Now let's set gmail to the default in Opera. (Yay Opera!)
#!/bin/sh
# system \ Pref \ Pref App -> ~/bin/gmailto "%s"
# (IN OPERA) Tools \ Preferences \ Programs \ mailto \ Open with Other App "~/bin/gmailto"
opera -newpage "https://mail.google.com/mail/?view=cm&tf=0&to=`echo $1 | sed "s/mailto://"`"
Nice tip. Traditionally, such a script would be placed into ~/bin (and the corresponding path name used in the pref box of course).
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. (http://www.atomeo.com/2007/05/13/set-google-apps-for-your-domain-as-default-mail-client-in-ubuntu/)
Worked for me first try……….thanks a bunch!
Cutting-and-pasting the script does not quite work for me, and it is almost certainly a character encoding issue.
Me:
Ubuntu 6.06LTS
Firefox 1.5.0.11
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 http://www.pemberley.com/janeinfo/latin1.html 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: `
Later…
The suggestions for kde are great. They worked perfect except for Firefox, but that was easy too.
about:config
create-> new string
network.protocol-handler.app.mailto /home/geek/open_mailto.sh
good to go, and thanks for the script!!
Here's my script:
#!/bin/sh
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( https://mail.google.com/mail?view=cm&$gmailargs, new-tab )"
I think it covers the entirety of mailto: possibilities. Thank you http://www.ianr.unl.edu/internet/mailto.html.
Woa, there David! A few too many seds in a row. Try this one instead.
#!/bin/sh
#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
# remove the ? from the uri
uri=`echo "$1″ | sed -e 's/subject=/su=/' -e 's/^mailto:\([^&?]\+\)[?&]\?\(.*\)$/\1\&\2/'`
firefox "https://mail.google.com/mail?view=cm&tf=0&to=$uri"
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?
I'm having the exact same error as dfreer.
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.
I try clicking on an html mailto: form, like this one.
somebody@somewhere.com
the code looks like this (only with brackets):
a href="mailto:somebody@somewhere.com" somebody@somewhere.com
here's my open_mailto.sh script (note, everything else works fine it just doesn't put the email address in the gmail form):
[CODE]
#!/bin/sh
# This script, when set as default mail handler in
# System > Preferences > Preferred Applications
# Will use gmail as the mail client!
firefox -remote "openurl(https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`,new-tab)"
[/CODE]
Hi, again. A simple addition to the script to make it work with Firefox's "File->Send Link" functionality:
#!/bin/sh
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'`
fi
$FIREFOX "https://mail.google.com/mail?view=cm&tf=0&to=$TO"
Having the same problem as dfreer using Ubuntu feisty and firefox 2.0.0.4. Everything works except email addr does not appear in "To:" line.
Keep it short and sweet, people.
#!/bin/sh
FIREFOX=$(which firefox)
URL=$(echo $1 | sed 's#mailto:##;s#?#\&#;s#\&subject=#\&su=#i;')
$FIREFOX -remote "openurl(https://mail.google.com/mail?view=cm&tf=0&to=$URL)"
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 someone@example.com yields [https://mail.google.com/mail/?view=cm&tf=0&to=&fs=1] in the address bar. The console command [./open_mailto.sh someone@example.com] yields a result of [https://mail.google.com/mail/?view=cm&tf=0&to=someone@example.com&fs=1]
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.
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/open_mailto.sh %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.
Mike,
Thanks for that… typo in the article…
right mouseclick > send link, doesn't work
Thanks mike, that fixed the problem! it works great now.
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 https://mail.google.com/mail?view=cm\&tf=0\&to=`echo $1 | sed 's/mailto://'`
YAHOO!
I use fedora, but I think the instructions are the same regardless. I edited Jeff Waugh's instructions above for yahoo.com (thanks Jeff!):
#!/bin/sh
FIREFOX=$(which firefox)
URL=$(echo $1 | sed 's#mailto:##;s#?#\&#;s#\&subject=#\&Subj=#;s#(##;s#)##i;')
$FIREFOX -remote "openurl(http://us.f368.mail.yahoo.com/ym/Compose?To=$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.
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
Using Feisty with FF 2.0.0.5, the first script does not work unless double quotes are added around the URL, like so:
#!/bin/sh
firefox "https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`"
super-freaking-cool. Thanks.
Any way this command can simply be executed from the Preferred Applications utility, rather than calling a script?
concise, effective and very easy to use. thanks!
Strange, I can't get it to work properly. In FF I had to create a string named network.protocol-handler.app.mailto with a value of /home/geek/open_mailto.sh %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?
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!!
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…
#!/bin/sh
#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
# The first sed changes 'subject' to 'su' (gmail uses su instead)
# The second sed removes the 'mailto:' from a standard mailto:bob@foo.bar
# The third sed is described below
#
# When we get something a link from Firefox (others?) that is a "Send Link", it comes as
# mailto:?body=http%3A%2F%2Ffoo.bar
# Which we want to turn into
# &body=http%3A%2F%2Ffoo.bar
#Script adapted from post http://www.howtogeek.com/howto.....ment-16706
# by Vernon Mauery
URI=`echo "$1″ | sed -e 's/subject=/su=/' -e 's/^mailto:\([^&?]\+\)[?&]\?\(.*\)$/\1\&\2/' -e 's/^mailto:[?]\(.*\)$/\&\1/'`
firefox "https://mail.google.com/mail?view=cm&tf=0&to=$URI"
Thanks for the subject fix Chris!
But none of the suggestions here can make it work from both firefox and konqueror?
great little hack love it and easy to do.
@Chris
Nice fix… I had a little problem with it
I had to change,
URI=`echo "$1″ | sed…
to
URI=`echo $1 | sed…
the quotes messed it up I guess
I'm running Ubuntu 7.04 Feisty
Thanks all
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.
Thanks to all!
I think this is the best (based on JDS's script):
#!/bin/sh
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'`
fi
firefox -remote "openurl(https://mail.google.com/mail?view=cm&tf=0&to=$ARGS,new-tab)"
place it in /usr/local/bin
you have to create it as root with sudo gedit open_mailto.sh (or similar)
then use this command: chmod a+x filepath
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?
thanks.
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.
mine works when i execute the script from a terminal, but when i click a mailto: link, it does not launch firefox.
any suggestions?
Hi,
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:
#!/bin/sh
gnome-open https://mail.google.com/mail?view=cm\&tf=0\&to=`echo $1 | sed 's/mailto://'`
note that "gnome-open" makes it use your preferred browser instead of hardcoding firefox.
Cheers,
Karel Demeyer.
is there anything we can't do w/ ubuntu?:> I love how greatly customizable it is!
> is there anything we can't do w/ ubuntu?
Get any real work done…
Thank you very much, that's what I was looking for, for a very long time.
double thumbs up
anyone got this message from gmail:
mail.google.com has sent and incorrect or unexpected message. Error Code: -12263
whatever script is used?
Thank you, this is extremely nice. I saw this (in a round-about fashion) from lifehacker, I hope they update to link your site.
Cool stuff.
Actually, though real geeks access Gmail via IMAP and Mutt
Hi,
I define
about:config
create-> new string
network.protocol-handler.app.mailto /home/geek/open_mailto.sh
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
les
I guess you can write a script and all that, or just in the custom slot put
firefox -new-tab https://mail.google.com/mail?view=cm&tf=0&to=
my accuont has been disabled. pls help me to log to dat same id , thank you
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: http://www.e-sante.be/magazine.....;urlnew=0, 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 e-sante.be :%0D%0A%0D%0Ahttp://www.e-sante.be/be/magazine_sante/femmes_leur_sante/acne_post_adolescente_essentiellement_feminine-7416-950-art.htm%0D%0A%0D%0ATr%C3%A8s bonne lecture et %C3%A0 bient%C3%B4t !%0D%0A%0D%0Ae-sante.be, 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%0Ahttp://www.e-sante.be/be/magazine_sante/newsletter_inscription.htm%0D%0A%0D%0A%0D%0A%0D%0Ahttp://www.e-sante.be&subject=Un article d'e-sante.be"
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.
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.
I think the new Gmail version broke this script. Now the Compose URL is https://mail.google.com/mail/#compose and I'm not sure how to pass arguments to this format. Any ideas?
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 2.0.0.11):
#!/bin/sh
firefox "https://mail.google.com/mail?view=cm&tf=0&ui=1&to=`echo $1 | sed 's/mailto://'`"
Cheers!
Simple change will try to open tab and if that fails open new firefox:
#!/bin/sh
if [ "$1″ ]; then
URL="https://mail.google.com/mail?view=cm&tf=0&to="`echo $1 | sed -e 's/subject=/su=/' -e 's/^mailto:\([^&?]\+\)[?&]\?\(.*\)$/\1\&\2/'`
else
URL="https://mail.google.com/mail"
fi
if ! firefox -remote "openurl(${URL}, new-tab)"; then
firefox ${URL}
fi
# EOF
Looks like Google changed things yet again. This line works for me, as of 30 Jan 2008:
#!/bin/sh
firefox "https://mail.google.com/mail?view=cm&tf=0&ui=1&to="`echo $1|sed -e 's/?subject=/\&su=/' -e 's/mailto://'`
Fantastic! Thanks.
Really gr8 tip. And it (the main description) works fine for me!
Thx.
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.
#!/bin/sh
opera –remote \
"openURL(https://mail.google.com/mail?view=cm&tf=0&to=${1/mailto:/},new-page)"
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(https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed s/mailto://`,new-page)"
Many thanks to the previous post, I didn't know about the openURL method
Cheers
To the previous post. How about this: ${f##*:}? (instead of ${1/mailto:/}
#!/bin/sh
opera –remote \
"openURL(https://mail.google.com/mail?view=cm&tf=0&to=${1##*:},new-page)"
We don't even need a separate file. Simply put this in the custom command field:
firefox "https://mail.google.com/mail?view=cm&tf=0&to=${%s/mailto:/}"
This works for me in Ubuntu 7.10, Firefox 2.0.0.12.
@ 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 "${mailto:geek@howtogeek.com/mailto:/}" instead of just the email address…. any idea how to correct this?
[Please ignore my previous comment. I made a mistake. Thanks Thomas!]
*************************
THE ONE-LINE SOLUTION!!!
*************************
If you have Perl installed, simply copy and paste this into the custom command field!
perl -e 'q/%s/=~/^mailto:(.*)$/;`firefox "https://mail.google.com/mail?view=cm&tf=0&to=$1″`;'
This works for me in Ubuntu 7.10, Firefox 2.0.0.12, with Perl 5.8.8. I double-checked this time!
@xyz
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//mail.google.com/mail?view=cm&tf=0&to=youremail@blah.com…."
I'll just say that what I have below works okay for me. YMMV it would appear!!
opera -remote \
"openURL(https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed s/mailto://`,new-page)"
@XYZ
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
@xyz
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.
Sometimes I'd get an error with opera for some addresses (long ones?).
After fiddling a bit, this fixed the problem:
~/gmail/mailto.sh "%t"
(put quotes around %t)
This is quite handy, thanks!
*************************
THE ONE-LINE SOLUTION!!! *** UPDATED ***
************************* (now supports "?subject=")
perl -e 'q/%s/=~/^mailto:(.*?)(?:\?subject=(.*))?$/;`firefox "https://mail.google.com/mail?view=cm&tf=0&to=$1&su=$2″`;'
excellent, i had to change the browser to swiftfox cause thats what i use, but really good stuff just the same
Thank you very much!!!!!!!!!!!!!
Here's a version that will handle "Send Link" as well as mailto URLs…..
http://dcc.vu/ubuntu-linux-fil.....gmail.html
this is awesome. thanks a ton, man!
this worked fine in gutsy…a bit different in hardy though….i can't get it to work again
sorry bout that, it does work, i just forgot that after the hardy install i have a new username
all is good