Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically open default email client and pre-populate content

I need to automatically open a user's default email client when they save some content on a page. I need to populate the email subject, to address, and put some content in the email body.

What is the best option to achieve this?

I'm aware of the mailto: attribute, but the user must click on this and I'm not sure it allows you to specifiy the subject and content?

like image 856
Thomas Buckley Avatar asked Nov 05 '12 11:11

Thomas Buckley


People also ask

How do I open an email client in HTML?

HTML <a> tag provides you option to specify an email address to send an email. While using <a> tag as an email tag, you will use mailto: email address along with href attribute. Following is the syntax of using mailto instead of using http. This code will generate the following link which you can use to send email.

How do I change my default email to open?

Change Windows 10 Default Email App To set your favorite email client as the system-wide default, head to Settings > Apps > Default Apps. Then in the right panel under the Email section, you will see it is set to the Mail app. Just click on it and choose the email app you want to use as the default from the list.

How do I change the default email opener on my Mac?

Choose Mail > Preferences, then click General. Choose an email app from the ”Default email reader” menu.

How do I set the default Mail client in Windows 11?

Or you can right-click the Start button in your taskbar and select “Settings.” When Settings opens, click “Apps” in the sidebar, and then select “Default Apps.” In Default Apps, click the search bar and type in the name of the email app you'd like to use as your default.


1 Answers

As described by RFC 6068, mailto allows you to specify subject and body, as well as cc fields. For example:

mailto:[email protected]?subject=Subject&body=message%20goes%20here 

User doesn't need to click a link if you force it to be opened with JavaScript

window.location.href = "mailto:[email protected]?subject=Subject&body=message%20goes%20here"; 

Be aware that there is no single, standard way in which browsers/email clients handle mailto links (e.g. subject and body fields may be discarded without a warning). Also there is a risk that popup and ad blockers, anti-virus software etc. may silently block forced opening of mailto links.

like image 51
jsalonen Avatar answered Sep 28 '22 04:09

jsalonen