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

I am developing a website.

What opens mailto: if there is no mail client (for example, Outlook, Thunderbird, etc.)? It works on my computer that has Outlook, but what if you want mailto: open, say, gmail.com?

What do I need to do in the mailto: instruction for this?

+6
source share
5 answers

As a web developer, you have no control over the software that the user chooses to open his e-mail, because he is processed by these settings of the user's web browser or operating system. If the user does not have an email program installed on their machine and no operation is defined for the mailto links in their browser, nothing will happen.

+9
source

I believe you can use this. https://mail.google.com/mail/?view=cm&fs=1& to=email@domain.com However, this has its drawbacks in which the user must already be subscribed to gmail. Hope this helps!

+1
source

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); 

See https://www.uncinc.nl/articles/dealing-with-mailto-links-if-no-mail-client-is-available for details

+1
source

What happens is entirely up to the customer. The OS defines protocol handlers for protocols such as mailto: or tel: etc.

You will need access to the client registry (in the case of the Windows system) in order to manipulate the processing application for your protocol handler.

For Outlook 2013 as an assigned handler, the corresponding registry structure is as follows:

 [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 the corresponding structure at HKCU.

0
source

The mailto URI mailto does not determine what is happening - it simply instructs the browser that you use to do everything that has been configured to send email (see the proposed IETF standard for more information ). Therefore, you will need to consult the browser itself to find out what it does if the email client is not configured.

According to the documentation and my personal experience, I see no way to manually set the action: perhaps with some browsers with non-standard syntax, but this is unlikely, as this will open up a huge potential security problem, being able to execute an arbitrary command by clicking (for example, load a virus or something like that).

0
source

Source: https://habr.com/ru/post/978802/


All Articles