Поставил nodemailer на ноду
и настроил:
nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport('smtps://имя@gmail.com:пароль@smtp.gmail.com');
app.post('/SendForm', function(req, res) {
var template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html class=" js no-touch"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body style="width: 600px; margin: auto;">'
template += 'Форма: '+req.body.type+'<br>';
template += 'Имя: '+req.body.name+'<br>';
template += 'Телефон: '+req.body.telefon+'<br>';
template += 'Позвоните мне: '+req.body.callme+'<br>';
template += 'Whats app: '+req.body.whatsapp+'<br>';
template += '</body></html>';
var mailOptions = {
from: 'accnccall@gmail.com', // sender address
to: 'accnccall@gmail.com', // list of receivers
subject: 'Форма от '+req.body.name, // Subject line
html: template // 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);
});
res.end();
});