Change mailto: links to ZCS Mailto: links

When you click on a mailto: link, most of the time your Firefox will launch that version of Outlook Express or Apple Mail you never configured. For the novice user, they click next, next, next, next, then send their e-mail…and it never gets delivered. Well using a greasemonkey script that we’ll convert to a firefox extension, we can handle the mailto links.

This morning, I clicked on a link thinking it would take me to a “Contact us” form, but it was a mailto: link. I was a little annoyed that Apple Mail opened, and I thought: I wonder if there’s a way to change that link to open ZCS?

Well, I found a cool little hack using GreaseMonkey and a site that compiles GreaseMonkey scripts to an xpi extension.

First, some pre-requisites:
You’ll need ZCS 4.5.0 or newer.
This is a Firefox only hack. Sorry IE and Safari users.


First, go to this URL:
http://userscripts.org/scripts/review/595?format=txt

This is a GreaseMonkey script for GMail. All we’re going to do is change the URL from GMail to your ZCS server. The script is licensed under GPL, and if you use it, please note that you MUST abide by the coder’s License guidelines. The script was written by Julien Couvreur.

Copy all of the text to your favorite text editor.

Now, in your text editor, you’re going to change a few lines.

Change:
# // ==UserScript==
# // @name Mailto Compose In GMail
# // @namespace http://blog.monstuff.com/archives/000238.html
# // @description Rewrites “mailto:” links to GMail compose links
# // @include *
# // @exclude http://gmail.google.com
# // ==/UserScript==

To:
# // ==UserScript==
# // @name Mailto Compose In Zimbra
# // @namespace http://blog.monstuff.com/archives/000238.html
# // @description Rewrites “mailto:” links to Zimbra compose links
# // @include *
# // @exclude http://mail.domain.com
# // ==/UserScript==

**Replace https and mail.domain.com with your server name.

and Change:
mailtoLink.href = “https://mail.google.com/mail?view=cm&tf=0” +
(emailTo ? (“&to=” + emailTo) : “”) +
(emailCC ? (“&cc=” + emailCC) : “”) +
(emailSubject ? (“&su=” + emailSubject) : “”) +
(emailBody ? (“&body=” + emailBody) : “”);
// mailtoLink.onclick = function() { location.href = newUrl; return false; };

To:
mailtoLink.href = “https://mail.server.com/zimbra/h/search?action=compose” +
(emailTo ? (“&to=” + emailTo) : “”) +
(emailCC ? (“&cc=” + emailCC) : “”) +
(emailSubject ? (“&subject=” + emailSubject) : “”) +
(emailBody ? (“&body=” + emailBody) : “”);
// mailtoLink.onclick = function() { location.href = newUrl; return false; };

**Be sure to replace https with http or https (depending on if you use SSL). Also, be sure to replace mail.server.com with your Zimbra server address.


Now, go to this website:
http://arantius.com/misc/greasemonkey/script-compiler

And fill in the text areas. Leave the GUID the same, and copy and paste your new script into the script text area, then hit compile.

It will ask you to save the xpi file. Once you save it, Open Firefox, then click file->Open and locate your XPI. Restart firefox, and all of your mailto: links now point to the Zimbra server.

Thanks and credit go to:
Julien Couvreur who wrote the script
Anthony Lieuallen for the web based GreaseMonkey to Firefox Extension converter
cubicgarden for the flickr GreaseMonkey photo.

Gmail™ webmail service is a registered trademark of Google, Inc.
Firefox is a registered trademark of Mozilla, Inc.
Also, these sites and scripts are not hosted or affiliated with Zimbra or Yahoo.

2 Responses to Change mailto: links to ZCS Mailto: links

  1. is cloud computing April 14, 2012 at 3:58 AM #

    Pretty nice post. I just stumbled upon your blog and wanted to mention
    that I’ve truly enjoyed browsing your weblog posts. After all I will be subscribing in your feed and I am hoping you write again soon!

  2. Dim July 24, 2012 at 8:33 PM #

    I wouldn’t touch zimbra’s mailto link handling until they fix the bugs with broken links – http://www.zimbra.com/forums/administrators/57555-mailto-links-getting-cut-webgui.html#post244951
    Atm it looks like the Zimbra guys abandoned the forums and don’t care about bugs any longer either.

Copyright © 2022 Zimbra, Inc. All rights reserved.

All information contained in this blog is intended for informational purposes only. Synacor, Inc. is not responsible or liable in any manner for the use or misuse of any technical content provided herein. No specific or implied warranty is provided in association with the information or application of the information provided herein, including, but not limited to, use, misuse or distribution of such information by any user. The user assumes any and all risk pertaining to the use or distribution in any form of any subject matter contained in this blog.

Legal Information | Privacy Policy | Do Not Sell My Personal Information | CCPA Disclosures