Can I set subject/content of email using mailto:?
当我使用mailto时,是否可以设置邮件的主题/内容?
Yes, look all tips and tricks with mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm
mailto subject example:
<a href="mailto:no-one@snai1mai1.com?subject=free chocolate">example</a>
mailto with content:
<a href="mailto:?subject=look at this website&body=Hi,I found this website
and thought you might like it http://www.geocities.com/wowhtml/">tell a friend</a>
As alluded to in the comments, both subject
and body
must be escaped properly. Use encodeURIComponent(subject)
on each, rather than hand-coding for specific cases (like %0A
for line breaks).
<a href="mailto:manish@simplygraphix.com?subject=Feedback for
webdevelopersnotes.com&body=The Tips and Tricks section is great
&cc=anotheremailaddress@anotherdomain.com
&bcc=onemore@anotherdomain.com">Send me an email</a>
您可以使用此代码来设置主题,正文,抄送,密送
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 the body
and subject
headers into a URL (URI):
mailto:infobot@example.com?subject=current-issue&body=send%20current-issue
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:
<a href="mailto:infobot@example.com?subject=current-issue&body=send%20current-issue">Send email</a>
And most generally, here is a simple PHP script that encodes per the above.
<?php
$encodedTo = rawurlencode($message->to);
$encodedSubject = rawurlencode($message->subject);
$encodedBody = rawurlencode($message->body);
$uri = "mailto:$encodedTo&subject=$encodedSubject&body=$encodedBody";
$encodedUri = htmlspecialchars($uri);
echo "<a href="$encodedUri">Send email</a>";
?>
链接地址: http://www.djcxy.com/p/16552.html