Mir Vaux
Mir Vaux

Reputation: 101

How can I catch mailto with javascript and redirect to browser mail like gmail?

I'm mailing a form to myself with javascript - is there any way I can catch the clicks and send the form text to browser mail clients like gmail and hotmail?

I'm using this method as far:


function sendMail() {
    var link = "mailto:[email protected]"
             + "?cc="
             + "&subject=" + escape("inquiry via mysite.com")
             + "&body=" + escape(document.getElementById('input2000char').value)
    ;

    window.location.href = link;
}


But this will only work for people with e-mail client installed.

Upvotes: 1

Views: 528

Answers (1)

Léo
Léo

Reputation: 33

I think this is something you can not control. For exemple, users can set Gmail as their default email client on their own like that : https://blog.hubspot.com/marketing/set-gmail-as-browser-default-email-client-ht

Besides, most OS have a default e-mail client (Mail on MacOS, Mail on Windows 10, Thunderbird on Ubuntu, etc...)

Upvotes: 1

Related Questions