const { Job } = require('flitter-jobs') class EMailJob extends Job { static get services() { return [...super.services, 'smtp', 'output'] } async execute(job) { const config = this.smtp.config() const transport = this.smtp.transport() const { data } = job const { from = config.default_sender, to, subject, html } = data this.output.info(`Sending mail to ${to}...`) try { await transport.sendMail({ from, to, subject, html, }) } catch (e) { this.output.error(e) } this.output.success(`Mail sent!`) } } module.exports = exports = EMailJob