Answer the question
In order to leave comments, you need to log in
Why does the nodemailer npm module throw an error when sending?
Good evening everyone!
Dear friends, please tell me what is the problem?
created a file with the code, installed nodemailer, did everything necessary to get the id, secret, token and inserted it into the right places in the code. I get an error on startup, what could be the problem?
here is the code
const nodemailer = require('nodemailer');
const xoauth2 = require('xoauth2');
var transporter = nodemailer.createTransport({
service: "gmail",
auth: {
xoauth2: xoauth2.createXOAuth2Generator({
user: 'моя почта',
clientId: "мой клиент айди",
clientSecret: "мой секрет",
refreshToken: "рефреш токен"
})
}
});
var mailOptions = {
from: "Alex <моя почта>",
to: "почта куда отправляется",
subject: "Nodemailer test",
text: "Hi Max"
};
transporter.sendMail(mailOptions, function(err, res){
if(err){
console.log("Ошибка");
} else{
console.log("Письмо ушло");
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question