refactor: extract inlined dkim options to config file

This commit is contained in:
Julien Oculi 2024-06-17 10:55:45 +02:00
parent 3e429732c8
commit 2f663f0e08
2 changed files with 9 additions and 4 deletions

5
config/dkim.json Normal file
View file

@ -0,0 +1,5 @@
{
"domainName": "cohabit.fr",
"keySelector": "sendmailY2024M03",
"privateKey": "/etc/ssl/certs/dkim_keys/dkimMailKey.pem"
}

View file

@ -1,9 +1,9 @@
// @deno-types="npm:@types/nodemailer"
import nodemailer from 'nodemailer'
import dkim from '../config/dkim.json' with { type: 'json' }
export async function transporter() {
const dkimPath =
'/home/julien/dkim_sendmail_keys/dkim_sendmail_cohabit_fr.pem'
const dkimPath = dkim.privateKey
const dkimPrivateKey = await Deno.readTextFile(dkimPath).catch((cause) => {
throw new Error(`unable to load DKIM private key from "${dkimPath}"`, {
cause,
@ -15,8 +15,8 @@ export async function transporter() {
newline: 'unix',
path: '/usr/sbin/sendmail',
dkim: {
domainName: 'cohabit.fr',
keySelector: 'sendmailY2024M03',
domainName: dkim.domainName,
keySelector: dkim.keySelector,
privateKey: dkimPrivateKey,
},
})