diff --git a/src/util/config/types/subconfigurations/email/SMTP.ts b/src/util/config/types/subconfigurations/email/SMTP.ts
index 85c286a3..cf81aec9 100644
--- a/src/util/config/types/subconfigurations/email/SMTP.ts
+++ b/src/util/config/types/subconfigurations/email/SMTP.ts
@@ -20,6 +20,8 @@ export class SMTPConfiguration {
host: string | null = null;
port: number | null = null;
secure: boolean | null = null;
+ starttls: boolean = false;
+ allowInsecure: boolean = false;
username: string | null = null;
password: string | null = null;
}
diff --git a/src/util/util/email/clients/SMTPEmailClient.ts b/src/util/util/email/clients/SMTPEmailClient.ts
index 5c469e0f..278a4198 100644
--- a/src/util/util/email/clients/SMTPEmailClient.ts
+++ b/src/util/util/email/clients/SMTPEmailClient.ts
@@ -34,7 +34,7 @@ export class SMTPEmailClient extends BaseEmailClient {
return;
}
// get configuration
- const { host, port, secure, username, password } = Config.get().email.smtp;
+ const { host, port, secure, starttls, allowInsecure, username, password } = Config.get().email.smtp;
// ensure all required configuration values are set
if (!host || !port || secure === null) return console.error("[Email] SMTP has not been configured correctly.");
@@ -45,24 +45,27 @@ export class SMTPEmailClient extends BaseEmailClient {
);
/* 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,
- },
- };
- }
+ const nodemailer_opts = {
+ host: host,
+ port: port,
+ secure: secure,
+ ...(starttls ? { requireTLS: true } : { ignoreTLS: true }),
+ ...(allowInsecure
+ ? {
+ tls: {
+ rejectUnauthorized: false,
+ },
+ }
+ : {}),
+ ...(username && password
+ ? {
+ auth: {
+ user: username,
+ pass: password,
+ },
+ }
+ : {}),
+ };
// construct the transporter
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|