今天要在一個老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 : "[email protected]",
Password : "password",
To : '[email protected]',
From : "[email protected]",
Subject : "測試案例",
Body : "收到請回複"
}).then(
message => alert(message)
);;
</script>
</html>
就是這麼簡單,隻使用了smtp.js的cdn。
如果要用到附件,請看官方demo。
下面是官方的網址:
https://www.smtpjs.com/