今天要在一个老web系统上实现批量发送邮件服务,没办法更改后台代码,只能写到前端了。
既然写到前端,安全性的问题就不要再说了,肯定不安全啊。
下面是Html代码:
<!DOCTYPE html>
<html>
<script src="https://smtpjs.com/v3/smtp.js">
</script>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
<script>
Email.send({
Host : "smtp.163.com",
Username : "username@163.com",
Password : "password",
To : 'mubiaoYouXiang@qq.com',
From : "sendEmail@163.com",
Subject : "测试案例",
Body : "收到请回复"
}).then(
message => alert(message)
);;
</script>
</html>
就是这么简单,只使用了smtp.js的cdn。
如果要用到附件,请看官方demo。
下面是官方的网址: