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

13,998

Solution 1

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.

Solution 2

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

Solution 3

I believe you can use this. https://mail.google.com/mail/?view=cm&fs=1&[email protected] This however does have its flaws in which the user must be already signed into gmail. Hope this helps!

Share:
13,998
Edward Karak
Author by

Edward Karak

Updated on June 03, 2022

Comments

  • Edward Karak
    Edward Karak almost 2 years

    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?

  • Matt
    Matt over 6 years
    Assuming that the user is logged in to (or even uses a) gmail account is, I would say, even worse than assuming they have their own mail client set up.