async function sendMail(data, result) {
let res = '<h2>FSY</h2>';
let total = 0;
for (let i = 0; i <result.length; i++) {
res += `<b><p>${result[i]['name']} - ${data.key[result[i]['id']]} - ${result[i]['cost'] * data.key[result[i]['id']]} руб</p></b>`;
total += result[i]['cost'] * data.key[result[i]['id']];
}
console.log(res);
res += '<hr>';
res += `Общая сумма ${total} руб`;
res += `<hr>Телефон: ${data.phone}`;
res += `<hr>Имя: ${data.username}`;
res += `<hr>Адрес доставки: ${data.address}`;
res += `<hr>Email: ${data.email}`;
//let testAccount = await nodemailer.createTestAccount();
let transporter = nodemailer.createTransport({
host: "smtp.mail.ru",
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: 'buy.int@bk.ru', // generated ethereal user
pass: 'XXXXXXXXXXXXX' // generated ethereal password
}
});
let mailOption = {
from: '<buy.int@bk.ru>',
to: "buy.int@bk.ru," + data.email,
subject: "заказ",
text: 'Hello world',
html: res
};
console.log(transporter)
let info = await transporter.sendMail(mailOption);
console.log("MessageSent: %s", info.messageId);
console.log("PreviewSent: %s", nodemailer.getTestMessageUrl(info));
return true;
}