Commit | Line | Data |
---|---|---|
9aef1431 | 1 | import { createTransport } from 'nodemailer' |
f8374594 | 2 | import type SMTPTransport from 'nodemailer/lib/smtp-transport/index.js' |
ded253e2 JB |
3 | import { ThreadWorker } from 'poolifier' |
4 | ||
ef083f7b | 5 | import type { WorkerData } from './types.js' |
9aef1431 | 6 | |
f8374594 | 7 | class SmtpClientWorker extends ThreadWorker< |
3a502712 JB |
8 | WorkerData, |
9 | SMTPTransport.SentMessageInfo | |
f8374594 | 10 | > { |
9aef1431 JB |
11 | public constructor () { |
12 | super({ | |
13 | nodemailer: async (workerData?: WorkerData) => { | |
f8374594 | 14 | return await createTransport(workerData?.smtpTransport).sendMail( |
3a502712 | 15 | // eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
67f3f2d6 | 16 | workerData!.mail |
9aef1431 | 17 | ) |
3a502712 | 18 | }, |
9aef1431 JB |
19 | }) |
20 | } | |
21 | } | |
22 | ||
23 | export const smtpClientWorker = new SmtpClientWorker() |