Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does `mailto:` do when there is no email client?

I am developing a website.

What does mailto: open in if there is no email client (like Outlook, Thunderbird, etc.)? It works on my computer, which has Outlook, but what if one wants mailto: to open in, say, gmail.com?

What do I need to put in the mailto: statement for that to happen?

like image 973
Edward Karak Avatar asked Nov 27 '14 18:11

Edward Karak


People also ask

What happens with mailto?

Email (mailto) links are used for linking directly to an email address, which will automatically launch an email browser when the link is clicked.

Do mailto links still work?

Mailto HTML Links Explained. HTML is nearly as old as the internet, and so is one of its most common schemes: mailto. And, even though so many things have changed since then, good ol' mailto is still widely used and taught in HTML courses all around the world.

How do I link my mailto to Outlook?

In the message, select the text or picture that you want to display as the link. On the Insert tab, click Link or Hyperlink. Under Link to, click E-mail Address. Either type the email address that you want in the E-mail address box, or select an email address in the Recently used e-mail addresses list.

How do I set Gmail as my default email client for mailto links?

Make Gmail the default email program to open email links in Chrome Browser. Settings. Go to the Privacy and security section. At the top, make sure Allow sites to ask to become default handlers for protocols (recommended) is turned on.


2 Answers

As a web developer you don't have any control over the software that a user chooses to open their email, since it's handled by that user's web browser settings, or the OS. If a user has no email program installed on their machine and no operation defined for "mailto" links in their browser, nothing would happen.

like image 163
Edward Coyle Jr. Avatar answered Sep 28 '22 02:09

Edward Coyle Jr.


The following solution works for me:

(function($)) {
  $('a[href^=mailto]').each(function() {
    var href = $(this).attr('href');
    $(this).click(function() {
      var t;
      var self = $(this);

      $(window).blur(function() {
        // The browser apparently responded, so stop the timeout.
        clearTimeout(t);
      });

      t = setTimeout(function() {
        // The browser did not respond after 500ms, so open an alternative URL.
        document.location.href = '...';
      }, 500);
    });
  });
})(jQuery);

For more info see: https://www.uncinc.nl/articles/dealing-with-mailto-links-if-no-mail-client-is-available

like image 39
MartijnHoutman Avatar answered Sep 28 '22 00:09

MartijnHoutman