You can use navigator.registerProtocolHandler()
to set specific domains to handle specific protocols as demonstrated by @PaulIrish at Getting Gmail to handle all mailto: links with registerProtocolHandler.
.registerProtocolHandler()
must be called at the origin where the protocol is to be handled by the web application, else an error occurs.
User agents must throw a "SecurityError" DOMException if the
resulting URL record has an origin that differs from the
origin specified by the relevant settings object of this
NavigatorContentUtils object.
For example, you can navigate to "https ://mail.google.com/mail/#inbox", then at console
navigator.registerProtocolHandler("mailto",
"https://mail.google.com/mail/?extsrc=mailto&url=%s",
"Gmail");
var email = `<a href="mailto:yourbestfriend@example.com?subject=registerProtocolHandler()%20FTW!&body=Check%20out%20what%20I%20learned%20at%20http%3A%2F%2Fupdates.html5rocks.com%2F2012%2F02%2FGetting-Gmail-to-handle-all-mailto-links-with-registerProtocolHandler%0A%0APlus%2C%20flawless%20handling%20of%20the%20subject%20and%20body%20parameters.%20Bonus%20from%20RFC%202368!" target="_blank">this mailto: link</a>`;
document.body.insertAdjacentHTML("beforeend", email);
document.body.querySelector("a[href^=mailto]:nth-last-of-type(1)").click();
which should launch a window
having title "Compose Mail", with Subject and Body populated.
To include "cc" you can place
cc=email@domain.com&
within the string following last
&
on the
?subject=
line, see mailto with multiple cc addresses.
Or write the service for your own online email application to achieve the same handling of requests for specific protocols.