Рас
function foo(email, password) {
return new Promise(function(resolve, reject) {
nodemailer.createTestAccount(function(err, account) {
var transporter = nodemailer.createTransport({
//service: 'Gmail',
host: 'smtp.ethereal.email',
port: 587,
secure: true, // use SSL
auth: {
user: account.user,
pass: account.pass
}
});
var message = {
from: '"Heano" <games.1212@yandex.ru>',
to: email,
subject: 'Регистрация ✔',
text: 'Твой пароль: '+ password,
html: 'Твой пароль:<b> '+ password+'</b>'
};
transporter.sendMail(message, function (err, info) {
if (err) {
resolve('Error:', err.message);
return;
}
resolve('Server responded with ' + info.response);
});
});
});
}
Два
foo('f@ya.ru', '1')
.then(function(info) {
console.log(info);
})
.catch(function(err) {
console.log(err);
});