-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmtp.js
34 lines (30 loc) · 875 Bytes
/
smtp.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
33
34
const nodemailer = require("nodemailer");
module.exports.send = async (scenario, subject, cb) => {
if (global.debug) console.log("Send email");
const message = {
from: scenario.from,
to: scenario.to,
subject: subject,
text: "",
};
let tls = scenario.smtp_tls ? {
rejectUnauthorized: false
} : false;
let transporter = {
host: scenario.smtp_host,
port: scenario.smtp_port,
tls: tls,
secure: false,
debug: true
};
if (scenario.smtp_user && scenario.smtp_password) {
transporter["auth"] = {
type: "login",
user: scenario.smtp_user,
pass: scenario.smtp_password,
};
}
const transport = nodemailer.createTransport(transporter)
await transport.verify();
return transport.sendMail(message, cb);
};