From 2f663f0e08cf3bbb2b93888ff737f818c05c716d Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Mon, 17 Jun 2024 10:55:45 +0200 Subject: [PATCH] refactor: extract inlined dkim options to config file --- config/dkim.json | 5 +++++ src/transporter.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 config/dkim.json diff --git a/config/dkim.json b/config/dkim.json new file mode 100644 index 0000000..8b639c7 --- /dev/null +++ b/config/dkim.json @@ -0,0 +1,5 @@ +{ + "domainName": "cohabit.fr", + "keySelector": "sendmailY2024M03", + "privateKey": "/etc/ssl/certs/dkim_keys/dkimMailKey.pem" +} diff --git a/src/transporter.ts b/src/transporter.ts index 248194d..410bd92 100644 --- a/src/transporter.ts +++ b/src/transporter.ts @@ -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, }, })