The Opera 10.0 snapshot released today includes a new feature that allows users to click on mailto links and have them open in web mail providers, such as Gmail, Yahoo! Mail, and Windows Live Hotmail. This is particularly useful for individuals that primarily use web mail instead of a standalone e-mail client.
In a clean install, clicking a mailto link will trigger the e-mail client selection dialog, which allows users to choose between using Opera Mail, the system default mailer, or various web mail providers. When you select a web mail provider (and check the "Do not show this dialog again" checkbox), all mailto links will open in the specified web mail provider and automatically fill in parts of the compose window. For instance, the maillto link above will put "Test Mail" in the compose window subject. Users can change their settings in Preferences > Advanced > Programs by editing the "mailto" handler.
The web mail providers currently supported are Gmail, Yahoo! Mail, and Windows Live Hotmail. Yahoo! Mail and Windows Live Hotmail will not work very well if you aren't running a recent browser.js, as neither official supports Opera. Furthermore, Yahoo! Mail currently only opens the welcome page, but doesn't open a compose window.
This feature works via a list of web mail providers in the webmailproviders.ini file in the "defaults" sub-directory of the Opera program directory. On Windows, for instance, the file will be in "C:\Program Files\Opera\defaults\" if you install Opera in "C:\Program Files\Opera\". On OS X, the file is in the Opera.app package in the "Contents/Resources/defaults/" directory. Opera will need to be restarted to pick up new/changed entries in the file. Web mail providers are defined via the following format:
[Gmail]
ID=1
URL=https://mail.google.com/mail/?extsrc=mailto&url=%s
ICON=http://mail.google.com/favicon.ico
- The provider name shown in the UI is enclosed in square brackets.
- ID is a unique integer identifier for each entry in the file.
- URL is the web mail provider's mailto handler URL. "%s" will be replaced with the clicked mailto URL. Currently, data and javascript URLs are allowed.
- Icon is a link to a favicon representing the web mail provider.
Some web mail providers do not have a mailto handler URL, but can prefill compose windows by specifying each parameter separately, e.g. "http://mail.google.com/mail/?view=cm&fs=1&to=%t&su=%s&body=%m&cc=%c&bcc=%b" where %t represents the message recipient, %s the message subject, %m the message body, %c CC'd recipients, and %b BCC'd recipients. The current implementation does not natively support this style of URL, but it is possible to get around this limitation using a javascript or data URL to process the clicked mailto URL into separate parameters. For instance, the following entry could be added to webmailproviders.ini to make Opera work with Opera Web Mail (special thanks to Michael A. Puls II for providing this URL):
[Operamail.com]
ID=4
URL=javascript:(function(uri)%7B%0D%0Afunction%20decode(s)%7Btry%7Breturn%20decodeURIComponent(s).replace(%2F%5Cr%5Cn%7C%5Cr%7C%5Cn%2Fg%2C%22%5Cr%5Cn%22)%3B%7Dcatch(e)%7Breturn%20%22Opera%20percent-decode%20error%22%3B%7D%7D%0D%0Afunction%20encode(s)%7Btry%7Breturn%20encodeURIComponent(s)%3B%7Dcatch(e)%7Breturn%20%22Opera%2520percent-encode%2520error%22%3B%7D%7D%0D%0Afunction%20escapeInvalidHH(s)%7Breturn%20s.replace(%2F%25(%3F!%5B0-9A-F%5D%7B2%7D)%2Fgi%2Cfunction()%7Breturn%20%22%2525%22%3B%7D)%3B%7D%0D%0Afunction%20escapeUnsafeHH(s)%7Breturn%20s.replace(%2F%2500%7C%2501%7C%2502%7C%2503%7C%2504%7C%2505%7C%2506%7C%2507%7C%2508%7C%250B%7C%250C%7C%250E%7C%250F%7C%2510%7C%2511%7C%2512%7C%2513%7C%2514%7C%2515%7C%2516%7C%2517%7C%2518%7C%2519%7C%251A%7C%251B%7C%251C%7C%251D%7C%251E%7C%251F%2Fgi%2Cfunction(match)%7Breturn%20encode(match)%3B%7D)%3B%7D%0D%0Afunction%20filterSingleLine(s)%7Breturn%20s.replace(%2F%5Cr%7C%5Cn%2Fg%2C%22%22)%3B%7D%0D%0Afunction%20MailtoURIParser(s)%7Bthis.parse(escapeUnsafeHH(escapeInvalidHH(%22to%3D%22%2Buri.substr(7).replace(%2F%5C%3F%2F%2C%22%26%22))))%3B%7D%0D%0AMailtoURIParser.prototype%3D%7Bparse%3Afunction(dataset)%7Bthis.to%3Dthis.subject%3Dthis.body%3Dthis.cc%3Dthis.bcc%3D%22%22%3Bvar%20ref%3Dthis%3Bdataset.replace(%2F(%5B%5E%3D%26%5D%2B)%3D(%5B%5E%26%5D*)%2Fg%2Cfunction(match%2Chname%2Chvalue)%7Bhname%3Ddecode(hname).toLowerCase()%3Bif(hname%3D%3D%22to%22)%7Bif(hvalue!%3D%22%22)%7Bif(ref.to!%3D%22%22)%7Bref.to%2B%3D%22%252C%2520%22%3B%7Dref.to%2B%3Dhvalue%3B%7D%7Delse%20if(hname%3D%3D%22cc%22)%7Bif(hvalue!%3D%22%22)%7Bif(ref.cc!%3D%22%22)%7Bref.cc%2B%3D%22%252C%2520%22%3B%7Dref.cc%2B%3Dhvalue%3B%7D%7Delse%20if(hname%3D%3D%22bcc%22)%7Bif(hvalue!%3D%22%22)%7Bif(ref.bcc!%3D%22%22)%7Bref.bcc%2B%3D%22%252C%2520%22%3B%7Dref.bcc%2B%3Dhvalue%3B%7D%7Delse%20if(hname%3D%3D%22subject%22)%7Bref.subject%3Dhvalue%3B%7Delse%20if(hname%3D%3D%22body%22)%7Bif(!(hvalue%3D%3D%22%22%26%26ref.body%3D%3D%22%22))%7Bif(ref.body!%3D%22%22)%7Bref.body%2B%3D%22%250D%250A%22%3B%7Dref.body%2B%3Dhvalue%3B%7D%7D%7D)%3Bthis.to%3Dencode(filterSingleLine(decode(this.to)))%3Bthis.subject%3Dencode(filterSingleLine(decode(this.subject)))%3Bthis.body%3Dencode(decode(this.body))%3Bthis.cc%3Dencode(filterSingleLine(decode(this.cc)))%3Bthis.bcc%3Dencode(filterSingleLine(decode(this.bcc)))%3B%7D%2Cformat%3Afunction(s)%7Bvar%20ref%3Dthis%3Breturn%20s.replace(%2F(%25%25)%7C(%25T)%7C(%25S)%7C(%25M)%7C(%25C)%7C(%25B)%7C(%25w)%2Fg%2Cfunction(match%2Ca%2Cb%2Cc%2Cd%2Ce%2Cf%2Cg)%7Bif(a)return%20%22%25%22%3Bif(b)return%20ref.to%3Bif(c)return%20ref.subject%3Bif(d)return%20ref.body%3Bif(e)return%20ref.cc%3Bif(f)return%20ref.bcc%3Bif(g)return%20encode(%22mailto%3A%22%2Bref.to%2B%22%3Fsubject%3D%22%2Bref.subject%2B%22%26body%3D%22%2Bref.body%2B%22%26cc%3D%22%2Bref.cc%2B%22%26bcc%3D%22%2Bref.bcc)%3B%7D)%3B%7D%7D%3B%0D%0Aif(uri.search(%2Fmailto%3A%2Fi)!%3D0)%7Bthrow%20%22Not%20a%20MailtoURI%22%3B%7D%0D%0Avar%20parser%3Dnew%20MailtoURIParser(uri)%3B%0D%0Avar%20compose%3Dparser.format(%22http%3A%2F%2Fmymail.operamail.com%2Fscripts%2Fmail%2FOutblaze.mail%3Fcompose%3D1%26did%3D1%26a%3D1%26to%3D%25T%26subject%3D%25S%26body%3D%25M%26cc%3D%25C%26bcc%3D%25B%22)%3B%0D%0Avar%20a%3Ddocument.createElementNS(%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%2C%22a%22)%3Ba.href%3Dcompose%3Ba.click()%3B%0D%0A%7D)(%22%s%22)%3B
ICON=http://www.opera.com/favicon.ico
This feature is a work in progress and we hope to work out all of the kinks with web mail providers before the final release of Opera 10.0.
Update (2009-01-13 2:25pm ET): The initial operamail.com URL was wrong and has now been updated.