我试图在nodemailer中使用node js发送邮件。但是我不确定如何不使用auth来使用node js发送邮件。
mail.js
const nodemailer = require('nodemailer');
const ejs = require('ejs');
const fs = require('fs');
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: 'xxx@gmail.com',
pass: 'xxx'
}
});
let mailOptions = {
from: '"xxx" <xxx@gmail.com>',
to: 'yyy@gmail.com',
subject: 'Teste Templete ✔',
html: ejs.render( fs.readFileSync('e-mail.ejs', 'utf-8') , {mensagem: 'olá, funciona'})
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});