-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.js
32 lines (28 loc) · 847 Bytes
/
sendmail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function sendEmail(fromName, emailData) {
const mailer = require('nodemailer');
const transporter = mailer.createTransport({
host: process.env.EMAIL_SMTP_HOST,
port: 465,
secure: true,
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS
}
});
const mailOptions = {
from: process.env.EMAIL_FROM,
to: process.env.EMAIL_TO,
subject: 'Запись на семинар от ' + fromName,
text: emailData
};
transporter.sendMail (mailOptions, function(error, info){
if (error) {
console.log(error);
return false;
} else {
console.log('Email sent: ' + info.response);
return true;
}
});
}
exports.sendEmail = sendEmail;