Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(backend): set up smtp pooling for nodemailer #8167

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ EMAIL_DEFAULT_SENDER="[email protected]"
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
Expand Down
2 changes: 2 additions & 0 deletions backend/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 3 additions & 0 deletions backend/src/middleware/helpers/email/sendMail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ if (!hasEmailConfig) {
port: CONFIG.SMTP_PORT,
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,
Expand Down
Loading