Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(backend:infrastructure): allow configuration of ignoreTLS and rejectUnauthorized for SMTP transport

johavenc1b3f5a810e2
diff --git a/backend/src/infrastructure/mailer/interfaces/mail.interface.ts b/backend/src/infrastructure/mailer/interfaces/mail.interface.ts
index cee96d08..b716c669 100644
--- a/backend/src/infrastructure/mailer/interfaces/mail.interface.ts
+++ b/backend/src/infrastructure/mailer/interfaces/mail.interface.ts
@@ -8,6 +8,7 @@ export interface MailTransport {
host: string
port: number
secure: boolean
+ ignoreTLS: boolean
auth: {
user: string
pass: string
diff --git a/backend/src/infrastructure/mailer/mailer.config.ts b/backend/src/infrastructure/mailer/mailer.config.ts
index 798be88d..e9ca878e 100644
--- a/backend/src/infrastructure/mailer/mailer.config.ts
+++ b/backend/src/infrastructure/mailer/mailer.config.ts
@@ -31,6 +31,14 @@ export class MailerConfig {
@IsBoolean()
secure?: boolean = false
+ @IsOptional()
+ @IsBoolean()
+ ignoreTLS?: boolean = false
+
+ @IsOptional()
+ @IsBoolean()
+ rejectUnauthorized?: boolean = true
+
@IsOptional()
@IsObject()
@ValidateNested()
diff --git a/backend/src/infrastructure/mailer/mailer.service.ts b/backend/src/infrastructure/mailer/mailer.service.ts
index 2a5784a6..53d1ebaa 100644
--- a/backend/src/infrastructure/mailer/mailer.service.ts
+++ b/backend/src/infrastructure/mailer/mailer.service.ts
@@ -38,9 +38,10 @@ export class Mailer {
port: this.configuration.port,
auth: this.configuration.auth,
secure: this.configuration.secure,
+ ignoreTLS: this.configuration.ignoreTLS,
logger: this.configuration.logger ? (this.logger as NodeMailLogger & any) : false
} satisfies MailTransport,
- { from: this.configuration.sender, tls: { rejectUnauthorized: false } } satisfies MailDefaultsTransport
+ { from: this.configuration.sender, tls: { rejectUnauthorized: this.configuration.rejectUnauthorized } } satisfies MailDefaultsTransport
)
this.verify().catch(this.logger.error)
}
diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yaml
index 64b145ae..c21c9d09 100755
--- a/environment/environment.dist.yaml
+++ b/environment/environment.dist.yaml
@@ -60,8 +60,16 @@ mail:
user: user
pass: password
# secure: defines if the connection should use SSL (if true) or not (if false)
+ # note: setting `secure: false` does not necessarily mean messages are sent in plaintext
+ # if the server supports STARTTLS, the connection is usually upgraded to TLS automatically
# default: `false`
secure: false
+ # ignoreTLS: if true, disables the use of STARTTLS even if the server advertises it
+ # default: false
+ ignoreTLS: false
+ # rejectUnauthorized: reject the connection if the server's TLS certificate is invalid
+ # default: true
+ rejectUnauthorized: true
# enable logger
# default: `false`
logger: false