From 6698107d82f0067496d44e72c729b302ce363743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20D=C3=B6tsch?= <aaron@fsmpi.rwth-aachen.de> Date: Sat, 5 Aug 2023 18:31:57 +0200 Subject: [PATCH] Add MAIL_SUBJECT_PREFIX env variable --- .env.example | 1 + docker-compose.yml.example | 1 + src/lib/server/mail.js | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 0a9d997..3bd95c7 100644 --- a/.env.example +++ b/.env.example @@ -11,3 +11,4 @@ MAIL_FROM_NAME="Getränkekasse" MAIL_TLS=true MAIL_AUTH_METHOD="plain" MAIL_REPLY_TO="getraenke@domain.tld" # optional, sets the reply-to header, useful if you don't read the mailbox of MAIL_USER +MAIL_SUBJECT_PREFIX="[Getränkekasse] " diff --git a/docker-compose.yml.example b/docker-compose.yml.example index b80af60..032ba14 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -38,6 +38,7 @@ services: MAIL_TLS: ${MAIL_TLS} MAIL_AUTH_METHOD: ${MAIL_AUTH_METHOD} MAIL_REPLY_TO: ${MAIL_REPLY_TO} + MAIL_SUBJECT_PREFIX: ${MAIL_SUBJECT_PREFIX} volumes: - ./article-images:/app/article-images diff --git a/src/lib/server/mail.js b/src/lib/server/mail.js index a1af296..716043d 100644 --- a/src/lib/server/mail.js +++ b/src/lib/server/mail.js @@ -21,8 +21,9 @@ const transporter = nodemailer.createTransport({ */ export async function sendMail({to, subject, text, html=false}) { const content = html ? {html: text} : {text}; + const subjectPrefix = process.env.MAIL_SUBJECT_PREFIX ?? ""; return transporter.sendMail({ - subject, + subject: subjectPrefix + subject, to, from: { address: process.env.MAIL_FROM_ADDRESS, -- GitLab