1、使用nodemailer模块
2、邮件发送代码
exports.send_email = function(req,res) {
//发件人信息设置
var smtpTransport = nodemailer.createTransport("SMTP",{
host: "smtp.163.com",
auth: {
user: "abc@163.com",//账户
pass: "123456"//密码
}
});
//邮件选项设置
var mailOptions = {
from: "mrluxh@163.com", // 发件人地址
to: "123@qq.com,123@139.com", //多个收件人用,分隔
subject: "Node.js发送邮件测试", // 主题
html: "<b>我是HTML格式内容</b>" // html body
}
//发送
smtpTransport.sendmail(mailOptions, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
smtpTransport.close();
res.send('ok');
});
}