是的,请使用 mailto 查看所有提示和技巧: http : //www.angelfire.com/dc/html-webmaster/mailto.htm
mailto 主题示例:
<a href="mailto:no-one@snai1mai1.com?subject=free chocolate">example</a>
mailto 内容:
<a href="mailto:no-one@snai1mai1.com?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>
正如评论中提到的那样, subject
和body
必须适当地转义。在每种情况下都使用encodeURIComponent(subject)
,而不是对特定情况进行手工编码。
如Hoody在评论中所述,您可以通过在字符串中添加以下编码序列来添加换行符:
%0D%0A // one line break
<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>
您可以使用此代码设置主题,正文,抄送,密件抄送
mailto:
URL 方案在RFC 2368 中定义。另外,在RFC 1738和RFC 3986 中定义了将信息编码为 URL 和 URI 的约定。这些规定了如何在 URL(URI)中包含body
和subject
标头:
mailto:infobot@example.com?subject=current-issue&body=send%20current-issue
具体来说,您必须对电子邮件地址,主题和正文进行百分比编码,然后将其放入上述格式。百分比编码的文本在 HTML 中使用是合法的,但是根据HTML4 标准 ,此 URL 必须是用于href
属性中的实体编码:
<a href="mailto:infobot@example.com?subject=current-issue&body=send%20current-issue">Send email</a>
最普遍的是,这是一个简单的 PHP 脚本,按上述内容进行编码。
<?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>";
?>
您可以使用以下任一种方式将添加的主题添加到 mailto 命令。将?subject out mailto 添加到 mailto 标签。
<a href="mailto:test@example.com?subject=testing out mailto">First Example</a>
我们还可以通过在标记的末尾添加&body 来在消息的正文中添加文本,如以下示例所示。
<a href="mailto:test@example.com?subject=testing out mailto&body=Just testing">Second Example</a>
除了正文,用户还可以键入&cc 或&bcc 来填写 CC 和 BCC 字段。
<a href="mailto:test@example.com?subject=testing out mailto&body=Just testing&cc=test1@example.com&bcc=test1@example.com">Third
Example</a>
mailto:joe@company.com?subject=Your+subject
这是窍门http://neworganizing.com/content/blog/tip-prepopulate-mailto-links-with-subject-body-text
<a href="mailto:tips@neworganizing.com?subject=Your+tip+on+mailto+links&body=Thanks+for+this+tip">tell a friend</a>
我将其分成几行以使其更具可读性。
<a href="
mailto:johndoe@gmail.com
?subject=My+great+email+to+you
&body=This+is+an+awesome+email
&cc=janedoe@gmail.com
&bcc=billybob@yahoo.com
">Click here to send email!</a>
是:
使用它来试验 mailto 表单元素和链接编码。
您可以在表单中输入主题,正文(即内容)等,单击按钮,然后查看可以粘贴到页面中的 mailto html 链接。
您甚至可以指定电子邮件中鲜为人知和使用的元素:抄送,密件抄送。
是的,您可以这样:
mailto: email@host.com?subject=something