可以的。cnode的邮件系统没问题。可能是你的邮箱不支持,用qq邮箱试试,并且记得在邮箱中设置开启SMTP服务噢。
var nodemailer = require('nodemailer');
var smtpTransport = nodemailer.createTransport("SMTP",{
host:"smtp.qq.com", //主机i
// secureConnection:true, //使用ssl
port:25,
auth:{
user:"123456@qq.com",
pass:"mypassword"
}
});
//设置邮件内容
var mailOptions = {
from:"123456@qq.com",
to: "5892553@qq.com",
subject:"hello world",
html: "thanks a lot for visiting欢迎"
}
//发送邮件
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
}else{
console.log('message sent:' + response.message);
}
smtpTransport.close();
});