Я пытаюсь использовать Nodemailer для отправки электронной почты с моей учетной записью GMail, но он не работает, он работает локально, но на моем удаленном сервере я получаю письмо от Google «Кто-то использует вашу учетную запись .... "Nodemailer и GMail с токенами доступа
Как я могу это сделать?
exports.contact = function(req, res){
var name = req.body.name;
var from = req.body.from;
var message = req.body.message;
var to = '******@gmail.com';
var transport = nodemailer.createTransport("SMTP", {
service: 'Gmail',
auth: {
XOAuth2: {
user: "******@gmail.com",
clientId: "*****",
clientSecret: "******",
refreshToken: "******",
}
}
});
var options = {
from: from,
to: to,
subject: name,
text: message
}
transport.sendMail(options, function(error, response) {
if (error) {
console.log(error);
} else {
console.log(response);
}
transport.close();
});
}
Ответить здесь - http://stackoverflow.com/q/24098461/4640499. –