mailer/src/transporter.ts

24 lines
610 B
TypeScript

// @deno-types="npm:@types/nodemailer@^6.4.15"
import nodemailer from 'nodemailer'
import dkim from '../config/dkim.json' with { type: 'json' }
export async function transporter() {
const dkimPath = dkim.privateKey
const dkimPrivateKey = await Deno.readTextFile(dkimPath).catch((cause) => {
throw new Error(`unable to load DKIM private key from "${dkimPath}"`, {
cause,
})
})
return nodemailer.createTransport({
sendmail: true,
newline: 'unix',
path: '/usr/sbin/sendmail',
dkim: {
domainName: dkim.domainName,
keySelector: dkim.keySelector,
privateKey: dkimPrivateKey,
},
})
}