Mailto 链接的缺点

使用 Mailto 链接非常简单和有用,但它也有许多用户的缺点。
Mailto 链接可能会导致出现在垃圾邮件中。
这是垃圾邮件发送者最常用的方式之一。

即使我们没有收到很多垃圾邮件,或者有一个很好的垃圾邮件过滤器,我们也无法摆脱垃圾邮件。
最好在上使用 Mailto 表单而不是 Mailto 链接。

如何创建 Mailto 链接

Mailto 链接用于重定向到电子邮件地址而不是网页 URL。
当用户单击 Mailto 链接时,访问者计算机上的默认电子邮件客户端会打开并建议向 Mailto 链接中提到的电子邮件地址发送消息。

要创建 Mailto 链接,我们需要使用 HTML <a> 标签及其 href 属性,并在其后插入一个“mailto:”参数,如下所示:

<a href="mailto:email@example.com">Send Email</a>

如果我们希望将电子邮件发送到多个地址,请用逗号分隔电子邮件地址:

<a href="mailto:email@example.com, secondemail@example.com">Send Email</a>

可以预先填写以下字段:

  • 主题 - 对于主题行,
  • cc - 用于发送副本,
  • bcc - 用于发送密件抄送,
  • body - 用于消息的正文文本。

如果我们想要一个已经填写好的主题字段,请将“主题”参数添加到 href 属性中:

<a href="mailto:email@example.com?subject=Mail from our Website">Send Email</a>

要将 CC 和 BCC 添加到电子邮件,请使用 href 属性上的“cc”或者“bcc”参数:

<a href="mailto:email@example.com?cc=secondemail@example.com, anotheremail@example.com, &bcc=lastemail@example.com&subject=Mail from our Website">Send Email</a>

要添加正文,请将“body”参数与其他参数一起使用:

<a href="mailto:email@example.com?cc=secondemail@example.com, anotheremail@example.com, &bcc=lastemail@example.com&subject=Mail from our Website&body=Some body text here">Send Email</a>

综上所述,我们将有以下示例。

创建mailto链接的示例:

<!DOCTYPE html>
<html>
  <head>
    <style>
      .main-content {
        width: 60%;
        height: 400px;
        padding: 20px;
        line-height: 28px;
      }
      footer {
        padding: 10px 20px;
      }
      a {
        color: #00aaff;
      }
    </style>
  </head>
  <body>
    <div class="main-content">
      <h1>测试标题</h1>
      <p>欢迎注册onitroad</p>
    </div>
    <footer>
      <p>onitroad 小组</p>
      <p>意见或者建议:
        <a href="mailto:info@onitroad.com?cc=secondemail@example.com, anotheremail@example.com, &bcc=lastemail@example.com&subject=Mail from our Website&body=Dear onitroad Team">发送邮件</a>
        <address>
        1234-18820-1234
      </address>
    </footer>
  </body>
</html>
日期:2020-06-02 22:15:07 来源:oir作者:oir