Skip to content

fix: use secure: true instead of smtps:// in mailer#1952

Merged
spaenleh merged 4 commits into
mainfrom
1921-smtp-secure
Jul 22, 2025
Merged

fix: use secure: true instead of smtps:// in mailer#1952
spaenleh merged 4 commits into
mainfrom
1921-smtp-secure

Conversation

@spaenleh
Copy link
Copy Markdown
Member

@spaenleh spaenleh commented Jul 21, 2025

In this PR:

  • fix Use smtp:// and set ‎secure: true for SSL/TLS #1921 Deprecation warning from NodeJs
    • add a MAILER_USE_SSL env var to control the use of SSL with the mailer. By default the value is to disable SSL in DEV and enable in PROD.
  • update the compose file for self hosted services to disable SSL (most likely that we will run in PROD but we do not have support for SSL.
  • add a helper function to convert an env var to a boolean value. it accepts true and 1 as truthy values any other value is considered false. We can provide a default value, when no default is provided, it is false.

@spaenleh spaenleh requested a review from pyphilia July 21, 2025 09:28
@spaenleh spaenleh self-assigned this Jul 21, 2025
@spaenleh spaenleh added the chore Generic task or chore label Jul 21, 2025
@spaenleh spaenleh changed the title 1921 smtp secure fix: use secure: true instead of smtps:// in mailer Jul 21, 2025
@pyphilia
Copy link
Copy Markdown
Contributor

pyphilia commented Jul 21, 2025

If I understood correctly the docs, smtps in the connexion string was settings secure: true fine
https://github.com/nodemailer/nodemailer/blob/8033604aed6d107dd9d44f6ede4508de3393e504/test/shared/shared-test.js#L30 (also used in docs: https://nodemailer.com/smtp#creating-a-transport )

I've spent time to understand TLS, STARTTLS, etc... but it's a mess. I think the best article was this one https://mailtrap.io/blog/starttls-ssl-tls/#Which-ports-are-used-for-Implicit-and-Explicit-SSLTLS
And I think the key of all this was: TLS is better than SSL. SMTPS was refering to SMTP+SSL, but today it also means SMTP+TLS. I think as long as we use TLS we are fine. So secure: true with port 467.

In the end I think using smtps in the connexion string was okay (since it results in secure=true), anyway this string is there to be stripped. I'm curious what was your source for deprecation.

https://docker-mailserver.github.io/docker-mailserver/latest/config/security/understanding-the-ports/#overview-of-email-ports

Copy link
Copy Markdown
Contributor

@pyphilia pyphilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for this PR 🧶

Comment thread src/di/container.ts Outdated
Comment thread src/config/helpers.ts
@sonarqubecloud
Copy link
Copy Markdown

@spaenleh spaenleh added this pull request to the merge queue Jul 22, 2025
Merged via the queue into main with commit 03fec6c Jul 22, 2025
8 checks passed
@spaenleh spaenleh deleted the 1921-smtp-secure branch July 22, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Generic task or chore v2.7.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use smtp:// and set ‎secure: true for SSL/TLS

2 participants