2021-04-23 14:49:47 +02:00
|
|
|
const nodemailer = require("nodemailer")
|
|
|
|
|
2021-04-23 19:07:39 +02:00
|
|
|
exports.createSMTPTransport = config => {
|
2021-04-23 14:49:47 +02:00
|
|
|
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()
|
|
|
|
}
|