CoreID/app/unit/SMTPUnit.js

30 lines
646 B
JavaScript

const { Unit } = require('libflitter')
const nodemailer = require('nodemailer')
class SMTPUnit extends Unit {
static get name() { return 'smtp' }
static get services() {
return [...super.services, 'configs']
}
config() {
return this.configs.get('smtp')
}
transport() {
return this._transport
}
async go(app) {
const config = this.config()
this._transport = nodemailer.createTransport({
host: config.host,
port: config.port,
secure: config.secure,
auth: config.auth,
})
}
}
module.exports = exports = SMTPUnit