nodejsはメール送信機能を実現します.
1178 ワード
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: '[email protected]',
pass: 'ljy6585529'
}
});
// setup email data with unicode symbols
let mailOptions = {
from: '"iPalmap" ', // sender address
to: `[email protected]`, // list of receivers
subject: ' ', // Subject line
text: message // plain text body
// html: ' ' // 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);
});
}