From 395b1c9b6a70020fe0ecb36558b46ffe0579b736 Mon Sep 17 00:00:00 2001 From: mahula Date: Mon, 20 Jan 2025 20:33:30 +0100 Subject: [PATCH 1/2] backend: active SMTP pooling in Nodemailer configuration --- backend/src/middleware/helpers/email/sendMail.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/middleware/helpers/email/sendMail.ts b/backend/src/middleware/helpers/email/sendMail.ts index c0e54e7f70..093d41e4cd 100644 --- a/backend/src/middleware/helpers/email/sendMail.ts +++ b/backend/src/middleware/helpers/email/sendMail.ts @@ -42,6 +42,7 @@ if (!hasEmailConfig) { port: CONFIG.SMTP_PORT, ignoreTLS: CONFIG.SMTP_IGNORE_TLS, secure: CONFIG.SMTP_SECURE, // true for 465, false for other ports + pool: true, auth: hasAuthData && { user: CONFIG.SMTP_USERNAME, pass: CONFIG.SMTP_PASSWORD, From b51ca1827d8fff2ae8314f586e918f161bd96d92 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 21 Jan 2025 12:59:32 +0100 Subject: [PATCH 2/2] backend: add max SMTPconnections and messages to Nodemailer configuration --- backend/.env.template | 2 ++ backend/src/config/index.ts | 2 ++ backend/src/middleware/helpers/email/sendMail.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/backend/.env.template b/backend/.env.template index d398c22659..ddade4e40c 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -12,6 +12,8 @@ EMAIL_DEFAULT_SENDER="devops@ocelot.social" SMTP_HOST= SMTP_PORT= SMTP_IGNORE_TLS=true +SMTP_MAX_CONNECTIONS=5 +SMTP_MAX_MESSAGES=Infinity SMTP_USERNAME= SMTP_PASSWORD= SMTP_SECURE="false" # true for 465, false for other ports diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 9f03622a59..b21796ef64 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -53,6 +53,8 @@ const smtp = { SMTP_DKIM_KEYSELECTOR: hasDKIMData && env.SMTP_DKIM_KEYSELECTOR, // PEM format: https://docs.progress.com/bundle/datadirect-hybrid-data-pipeline-installation-46/page/PEM-file-format.html SMTP_DKIM_PRIVATKEY: hasDKIMData && env.SMTP_DKIM_PRIVATKEY.replace(/\\n/g, '\n'), // replace all "\n" in .env string by real line break + SMTP_MAX_CONNECTIONS: env.SMTP_MAX_CONNECTIONS || 5, + SMTP_MAX_MESSAGES: env.SMTP_MAX_MESSAGES || 100, } const neo4j = { diff --git a/backend/src/middleware/helpers/email/sendMail.ts b/backend/src/middleware/helpers/email/sendMail.ts index 093d41e4cd..4b3e3b20af 100644 --- a/backend/src/middleware/helpers/email/sendMail.ts +++ b/backend/src/middleware/helpers/email/sendMail.ts @@ -43,6 +43,8 @@ if (!hasEmailConfig) { ignoreTLS: CONFIG.SMTP_IGNORE_TLS, secure: CONFIG.SMTP_SECURE, // true for 465, false for other ports pool: true, + maxConnections: CONFIG.SMTP_MAX_CONNECTIONS, + maxMessages: CONFIG.SMTP_MAX_MESSAGES, auth: hasAuthData && { user: CONFIG.SMTP_USERNAME, pass: CONFIG.SMTP_PASSWORD,