a href=mailto: 电子邮件链接

227 阅读1分钟

mailto 链接是一种 HTML 链接,可激活计算机上的默认邮件客户端以发送电子邮件。

基本语法

使用 a 标签创建一个 mailto 链接:

<a href="mailto:ming@163.com">send email</a>

或者:

<form action="mailto:ming@163.com">
  <!-- ... -->
</from>

测试链接:send email

image.png

mailto: 后面带的参数是收件人,参数列表如下:

参数描述
<><> 中的是收件人地址,如果没有尖括号,那么整个部分视作地址
mailto:ming@163.com
mailto:ming<ming@163.com>
;地址分隔符
mailto:ming<ming@163.com>;mei@163.com
?第一个参数分隔符(? 后面都是邮件参数)
&其他参数分隔符
cc=抄送地址
mailto:ming@163.com?cc=mei@163.com
bcc=密送地址
mailto:ming@163.com?bcc=mei@163.com
subject=邮件主题
mailto:ming@163.com?cc=mei@163.com&subject=test%20email
20% 是浏览器对于空格的编码
body=邮件内容
mailto:ming@163.com?subject=test%20email&body=Hi

实例

代码实现如下:

<a href="mailto:ming@163.com;han@163.com?cc=mei.163@com&bcc=lei@163.com&subject=meeting&body=Hi all,<br>You have a meeting at 10:00 this morning.">
  Send an email reminder to attend the meeting
</a>

邮件如下:

Send an email reminder to attend the meeting

image.png