From ef13c8c814df0a1e0636cc0d39d46f16422b0e38 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Sun, 30 Jun 2024 20:13:13 +0200 Subject: [PATCH] Add "email.senderAddress" config --- src/util/config/types/EmailConfiguration.ts | 1 + src/util/util/email/index.ts | 4 +++- src/util/util/email/transports/SMTP.ts | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/util/config/types/EmailConfiguration.ts b/src/util/config/types/EmailConfiguration.ts index ae9d53baf..62305d10b 100644 --- a/src/util/config/types/EmailConfiguration.ts +++ b/src/util/config/types/EmailConfiguration.ts @@ -25,6 +25,7 @@ import { SendGridConfiguration } from "./subconfigurations/email/SendGrid"; export class EmailConfiguration { provider: string | null = null; + senderAddress: string | null = null; smtp: SMTPConfiguration = new SMTPConfiguration(); mailgun: MailGunConfiguration = new MailGunConfiguration(); mailjet: MailJetConfiguration = new MailJetConfiguration(); diff --git a/src/util/util/email/index.ts b/src/util/util/email/index.ts index 619cc5c3f..d765f5ff5 100644 --- a/src/util/util/email/index.ts +++ b/src/util/util/email/index.ts @@ -187,7 +187,9 @@ export const Email: { const message = { from: - Config.get().general.correspondenceEmail || "noreply@localhost", + Config.get().email.senderAddress || + Config.get().general.correspondenceEmail || + "noreply@localhost", to: email, subject, html, diff --git a/src/util/util/email/transports/SMTP.ts b/src/util/util/email/transports/SMTP.ts index 5b43a8705..e3031943b 100644 --- a/src/util/util/email/transports/SMTP.ts +++ b/src/util/util/email/transports/SMTP.ts @@ -27,9 +27,12 @@ export default async function () { if (!host || !port || secure === null || !username || !password) return console.error("[Email] SMTP has not been configured correctly."); - if (!Config.get().general.correspondenceEmail) + if ( + !Config.get().email.senderAddress && + !Config.get().general.correspondenceEmail + ) return console.error( - "[Email] Correspondence email has not been configured! This is used as the sender email address.", + '[Email] You have to configure either "email_senderAddress" or "general_correspondenceEmail" for emails to work. The configured value is used as the sender address.', ); // construct the transporter