我可以使用mailto设置电子邮件的主题/内容:?

当我使用mailto时,是否可以设置邮件的主题/内容?

是的,使用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:?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> 

正如评论中提到的, subjectbody必须妥善地逃避。 对每一个使用encodeURIComponent(subject) ,而不是针对特定情况的手工编码(例如换行符为%0A )。

 <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命令的主题。 将邮件主题添加到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> 

除了正文之外,用户还可以input&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: URLscheme在RFC 2368中定义。 此外,在RFC 1738和RFC 3986中定义了将信息编码成URL和URI的约定。 这些规定如何将bodysubject标题包含到URL(URI)中:

 mailto:infobot@example.com?subject=current-issue&body=send%20current-issue 

具体来说,您必须对电子邮件地址,主题和正文进行百分比编码,并将其放在上面的格式中。 百分比编码的文本在HTML中是合法的,但是根据HTML4标准 ,这个URL必须是在href属性中使用的实体编码:

 <a href="mailto:infobot@example.com?subject=current-issue&amp;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:joe@company.com?subject=Your+subject 

是:

使用这个来试验mailto表单元素和链接编码。

您可以在表单中input主题,正文(即内容)等,点击button并查看您可以粘贴到页面的mailto html链接。

您甚至可以指定很less知道和使用的元素:抄送,密件抄送,从电子邮件。

这里是窍门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> 

是的,你可以这样做:

 mailto: email@host.com?subject=something 

我把它分成不同的行,使它更具可读性。

 <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> 

请注意,根据RFC 2368 ,不能在邮件正文中使用HTML:

特殊的hname“body”表示相关的hvalue是消息的主体。 “body”hname应该包含消息的第一个文本/纯文本部分的内容。 mailto URL主要用于生成实际上是自动处理内容的简短文本消息(例如邮件列表的“订阅”消息),而不是一般的MIME主体。

信用: https : //stackoverflow.com/a/13415988/1835519

如果你想添加HTML内容到你的电子邮件,URL编码你的邮件正文的HTML代码,并将其包含在你的mailto链接代码,但麻烦的是,你不能从这个链接从明文到HTML设置电子邮件的types,使用该链接的客户端默认情况下需要他们的邮件客户端发送html电子邮件。 如果你想在这里testing是一个简单的mailto链接的代码,一个图像包装在一个链接(angular样式url添加可见性):

 <a href="mailto:?body=%3Ca%20href%3D%22{{ scope.url }}%22%3E%3Cimg%20src%3D%22{{ scope.url }}%22%20width%3D%22300%22%20%2F%3E%3C%2Fa%3E"> 

html标签被url编码。