22 lines
479 B
JavaScript
22 lines
479 B
JavaScript
|
const nodemailer = require("nodemailer")
|
||
|
|
||
|
exports.createSMTPTransport = (config) => {
|
||
|
const options = {
|
||
|
port: config.port,
|
||
|
host: config.host,
|
||
|
secure: config.secure || false,
|
||
|
auth: config.auth,
|
||
|
}
|
||
|
if (config.selfSigned) {
|
||
|
options.tls = {
|
||
|
rejectUnauthorized: false,
|
||
|
}
|
||
|
}
|
||
|
return nodemailer.createTransport(options)
|
||
|
}
|
||
|
|
||
|
exports.verifyConfig = async config => {
|
||
|
const transport = exports.createSMTPTransport(config)
|
||
|
await transport.verify()
|
||
|
}
|