Is it possible to set the subject/content of email when I use mailto:?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
Note that it is not possible to use HTML in the message body, according to RFC 2368:
Credit: https://stackoverflow.com/a/13415988/1835519
The
mailto:
URL scheme is defined in RFC 2368. Also, the convention for encoding information into URLs and URIs is defined in RFC 1738 and then RFC 3986. These prescribe how to include thebody
andsubject
headers into a URL (URI):Specifically, you must percent-encode the email address, subject, and body and put them into the format above. Percent-encoded text is legal for use in HTML, however this URL must be entity encoded for use in an
href
attribute, according to the HTML4 standard:And most generally, here is a simple PHP script that encodes per the above.
Yes, look all tips and tricks with mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm
mailto subject example:
mailto with content:
As alluded to in the comments, both
subject
andbody
must be escaped properly. UseencodeURIComponent(subject)
on each, rather than hand-coding for specific cases (like%0A
for line breaks).You can add subject added to the mailto command using either one of the following ways. Add ?subject out mailto to the mailto tag.
We can also add text into the body of the message by adding &body to the end of the tag as shown in the below example.
In addition to body, a user may also type &cc or &bcc to fill out the CC and BCC fields.
How to add subject to mailto tag
I split it into separate lines to make it a little more readable.