Html 简明教程
HTML - Email Links
HTML email links 允许用户单击链接并自动使用已编写好指定电子邮件地址的新邮件打开其默认电子邮件客户端。
HTML email links allows users to click on a link and automatically open their default email client with a new message composed to the specified email address.
这是使用锚定(anchor)标签的 href 属性中的 mailto: 协议来完成的。
This is done using the mailto: protocol in the href attribute of an <a> (anchor) tag.
也可以使用 mailto: 协议预定义电子邮件的主题和正文。这是通过在电子邮件地址后面附加 ?subject= 和 &body= 来完成的。主题和正文中的空格和特殊字符应进行 URL 编码。例如,空格会编码为 %20。
You can also predefine the subject and body of the email using the mailto: protocol. This is done by appending ?subject= and &body= to the email address. Spaces and special characters in the subject and body should be URL-encoded. For example, spaces are encoded as %20.
Examples HTML Email Links
以下是一些通过 HTML 邮件链接进行使用情况说明的示例,
Following are some examples that illustrate usage of HTML Email link,
Create Email link using href
以下 HTML 代码说明了如何使用 <a> 标记的 href 属性创建一个电子邮件链接。
The following HTML code illustrates how to create an email link using the href attribute of <a> tag.
<!DOCTYPE html>
<html>
<body>
<p>
Creating an HTML Email Link
</p>
<a href= "mailto: name@email.com">
Click to Send Mail
</a>
</body>
</html>
Define Subject and Body in Email Link
HTML 还允许指定一个默认的 email subject 以及 email body ,以及电子邮件地址以使其更具体。
HTML also allows to specify a default email subject as well as email body along with the email address to make it more specific.
<!DOCTYPE html>
<html>
<body>
<p>
Creating an HTML Email Link
</p>
<a href="mailto:example@example.com?subject=Hello%20there&body=This%20is%20a%20predefined%20email%20body.">
Click here to Send Mail
</a>
</body>
</html>
Define cc and bcc in Email Link
还可以使用 cc 和 bcc 参数来添加抄送和密送收件人,如下面的示例所示
We can also use the cc and bcc parameters to add carbon copy and blind carbon copy recipients, as shown in the below example
<!DOCTYPE html>
<html>
<body>
<p>
Creating an HTML Email Link
</p>
<a href= "mailto: name@email.com ?cc=cc@example.com &bcc=bcc@example.com >
Send email with cc and bcc
</a>
</body>
</html>
Email Links for Multiple Recipients
也可以通过逗号分隔将多个收件人添加到电子邮件链接,如下面的 HTML 代码所示。
It is also possible to add multiple recipients to the email link by separating them with commas, as illustrated in the below HTML code.
<!DOCTYPE html>
<html>
<body>
<p>
Creating an HTML Email Link
</p>
<a href="mailto:recipient1@example.com, recipient2@example.com">
Send email to multiple recipients
</a>
</body>
</html>
Security Concerns
在网页上添加 HTML 电子邮件链接非常简单,但可能将你的电子邮件地址暴露给垃圾邮件。称为电子邮件收集器的自动化程序可以扫描网页中的电子邮件地址,然后将它们添加到垃圾邮件列表中。这会导致不需要的邮件大幅增加。
Adding an HTML email link to your webpage is straightforward, but it can expose your email address to spam. Automated programs, known as email harvesters, can scan web pages for email addresses and add them to spam lists. This can result in a significant increase in unwanted emails.