NodeMailer- отправка электронной почты в nodejs
Я новичок в nodejs и учусь на нескольких примерах. Я пытаюсь отправить электронное письмо с помощью nodemailer, используя следующий код:
var smtpConfig = {
host: 'smtp.gmail.com',
port: 465,
secure: true, // use SSL
auth: {
user: 'xxx@gmail.com',
pass: 'xxx@a'
}
};
var transporter = nodemailer.createTransport(smtpConfig);
// setup e-mail data with unicode symbols
var mailOptions = {
from: '"Fred Foo ?" <xxx@gmail.com>', // sender address
to: 'xxx@gmail.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ?', // plaintext body
html: '<b>Hello world ?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
}
Я получаю следующую ошибку при запуске:
Может кто-нибудь, дайте мне знать, где я делаю не так.
РЕДАКТИРОВАТЬ:
Проверенная конфигурация соединения с использованием кода ниже:
// verify connection configuration
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log('Server is ready to take our messages');
}
});
Проверка возвращает ошибку Error: connect ECONNREFUSED
Проверил это-
- Не проблема брандмауэра, так как она была отключена
- Включено - Доступ для менее безопасных приложений
Спасибо, WH