summary refs log tree commit diff
diff options
context:
space:
mode:
authorLisa Marie Maginnis <me@lisamarie.pro>2026-02-14 02:08:20 +0100
committerRory& <root@rory.gay>2026-02-14 18:00:56 +0100
commitda578f2cc3bd311822658eb7aaf4d5e3a16fe93e (patch)
treeddc39bbf8af836d39ad3a1d75e37ca3b7f365d25
parentFixed import of nodemailer ('nodemailer.default' does not exist) (diff)
downloadserver-ts-da578f2cc3bd311822658eb7aaf4d5e3a16fe93e.tar.xz
Allow for smarthosts/local SMTP relays that dont use user/pass AUTH
-rw-r--r--src/util/util/email/clients/SMTPEmailClient.ts32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/util/util/email/clients/SMTPEmailClient.ts b/src/util/util/email/clients/SMTPEmailClient.ts

index 41da066f..5c469e0f 100644 --- a/src/util/util/email/clients/SMTPEmailClient.ts +++ b/src/util/util/email/clients/SMTPEmailClient.ts
@@ -37,25 +37,37 @@ export class SMTPEmailClient extends BaseEmailClient { const { host, port, secure, username, password } = Config.get().email.smtp; // ensure all required configuration values are set - if (!host || !port || secure === null || !username || !password) return console.error("[Email] SMTP has not been configured correctly."); + if (!host || !port || secure === null) return console.error("[Email] SMTP has not been configured correctly."); if (!Config.get().email.senderAddress && !Config.get().general.correspondenceEmail) return console.error( '[Email] You have to configure either "email_senderAddress" or "general_correspondenceEmail" for emails to work. The configured value is used as the sender address.', ); + /* Allow for SMTP relays with and without username/passwords (IE: Smarthosts/Local Relays, etc) */ + let nodemailer_opts: unknown; + if(!username || !password) { + nodemailer_opts = { + host, + port, + secure, + }; + } else { + nodemailer_opts = { + host, + port, + secure, + auth: { + user: username, + pass: password, + }, + }; + } + // construct the transporter // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error - const transporter = this.nodemailer.createTransport({ - host, - port, - secure, - auth: { - user: username, - pass: password, - }, - }); + const transporter = this.nodemailer.createTransport(nodemailer_opts); // verify connection configuration const verified = await transporter.verify().catch((err: unknown) => {