const nodemailer = require('nodemailer');
```function senEmail(message) {
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: 'smtp.163.com',
port: 465,
secure: true, // secure:true for port 465, secure:false for port 587
auth: {
user: 'hello_jinyu@163.com',
pass: 'ljy6585529'
}
});
// setup email data with unicode symbols
let mailOptions = {
from: '"iPalmap" <hello_jinyu@163.com>', // sender address
to: `597396238@qq.com`, // list of receivers
subject: '定位发生异常', // Subject line
text: message // plain text body
// html: '<h1>定位发生异常</h1>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log("---------", error);
}
// console.log(info)
console.log('Message %s sent: %s', info.messageId, info.response);
});
}
网友评论