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

5

16

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?

Cathouse answered 27/11, 2014 at 18:19 Comment(2)
As far as I know mailto only opens those clients on the guest OS. If there is none, it doesn't work. There are some (chrome) plugins to make gmail your "default mail client". I fix this by creating a (php) from on my site and sending it that way.Hambletonian
I don't think it would work. I suggest having a form instead with Ajax.Caseous
E
14

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.

Enrika answered 27/11, 2014 at 18:27 Comment(0)
P
7

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

Papillose answered 2/8, 2016 at 12:56 Comment(0)
M
1

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!

Morley answered 27/11, 2014 at 18:27 Comment(1)
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.Aviv
A
0

What happens is entirely up to the client. The OS defines protocol handlers for protocols like mailto: or tel:, etc.

You would need access to the client's registry (in case of a Windows system) to manipulate the handling application for your protocol handler.

For Outlook 2013 as the designated handler, the according Registry structure looks like this:

[HKEY_CLASSES_ROOT\mailto]
@="URL:mailto"
"EditFlags"=hex:02,00,00,00
"URL Protocol"=""

[HKEY_CLASSES_ROOT\mailto\DefaultIcon]
@="C:\\PROGRA~2\\MICROS~1\\Office15\\OUTLOOK.EXE,-9403"

[HKEY_CLASSES_ROOT\mailto\shell]
@="open"

[HKEY_CLASSES_ROOT\mailto\shell\open]

[HKEY_CLASSES_ROOT\mailto\shell\open\command]
@="\"C:\\PROGRA~2\\MICROS~1\\Office15\\OUTLOOK.EXE\" -c IPM.Note /mailto \"%1\""

with a corresponding structure under HKCU.

Angling answered 27/11, 2014 at 18:25 Comment(0)
F
0

The mailto URI scheme doesn't decide what happens-- it simply instructs the browser you're using to do whatever it's been configured to do to send e-mails (see the IETF proposed standard for more info). Therefore, you'll have to consult the browser itself to see what it does if no e-mail client is configured.

According to the documentation and to my personal experience, I don't see any way of manually setting an action: It might be possible with certain browsers with some non-standard syntax, but this is unlikely since this would open up a huge potential security problem by being able to execute an arbitrary command by click (such as downloading a virus or something like that).

Foreclose answered 27/11, 2014 at 18:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.