5種前端實現(xiàn)郵件發(fā)送至指定郵箱的方式
方式1:利用a標簽的href屬性
"mailto:[email protected][email protected]&subject=主題&body=內容">send mail</a>
方式2:利用js中l(wèi)ocation
<script language=JavaScript>location="mailto:[email protected][email protected]&subject=主題&body=內容";script>
方式3:使用node中nodemail
npm install nodemailer --savenpm install nodemailer-smtp-transport --save
module.exports = {email: {//郵件配置service: '郵箱地址',user: '你的郵箱',pass: '你的密碼',}}
sendMail('[email protected]','這是測試郵件', '這是內容');
方式4:使用node的emailjs
npm install emailjs
var email = require("emailjs");var server = email.server.connect({user: "[email protected]", // 你的QQ用戶password:"xxxxxxxxx", // 注意,不是QQ密碼,而是剛才生成的授權碼host: "smtp.qq.com", // 主機,不改ssl: true // 使用ssl});//開始發(fā)送郵件server.send({text: "郵件內容", //郵件內容from: "[email protected]", //誰發(fā)送的to: "[email protected]", //發(fā)送給誰的subject: "郵件主題" //郵件主題}, function(err, message) {//回調函數console.log(err || message);});
方式5:使用jMail
評論
圖片
表情
