-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
t6config.js
46 lines (43 loc) · 1.4 KB
/
t6config.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
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
var t6config = module.exports = {};
global.transporter = {};
t6config.set_logLevel = function(value) {
logLevel = value; // LOG|DEBUG|INFO|WARNING|ERROR
};
t6config.set_smtp = function(smtp) {
mailhost = typeof smtp.mailhost!=="undefined"?smtp.mailhost:mailhost;
mailauth = typeof smtp.mailauth!=="undefined"?smtp.mailauth:mailauth;
let dkim = {
domainName : typeof smtp.dkim.domainName!=="undefined"?smtp.dkim.domainName:"",
keySelector : typeof smtp.dkim.keySelector!=="undefined"?smtp.dkim.keySelector:"",
}
mailDKIMCertificate = typeof smtp.mailDKIMCertificate!=="undefined"?smtp.mailDKIMCertificate:mailDKIMCertificate;
fs.access(mailDKIMCertificate, fs.constants.W_OK, (err) => {
if (err) {
transporter = nodemailer.createTransport({
host : mailhost,
port: 587,
ignoreTLS : true,
auth : mailauth,
dkim : {
domainName : dkim.domainName,
keySelector : dkim.keySelector
}
});
} else {
transporter = nodemailer.createTransport({
host : mailhost,
port: 587,
ignoreTLS : true,
auth : mailauth,
dkim : {
domainName : dkim.domainName,
keySelector : dkim.keySelector,
privateKey : fs.readFileSync(mailDKIMCertificate, "utf8")
}
});
}
t6console.log(`mailDKIMCertificate ${err ? "is not found. Transporter is not using DKIM" : "found. Transporter is using DKIM certificate."}`);
});
};
module.exports = t6config;