Skip to content

EMAIL_TLS_REJECT_UNAUTHORIZED=0 does not disable SMTP TLS certificate validation #644

@matt-rgx

Description

@matt-rgx

Describe the bug
EMAIL_TLS_REJECT_UNAUTHORIZED does not work as documented for SMTP magic-link login.

According to the docs and the PR that introduced it, setting EMAIL_TLS_REJECT_UNAUTHORIZED=0 should disable TLS
certificate validation for SMTP relays using self-signed certificates (for example ProtonMail Bridge).

In practice, SplitPro still fails with self-signed certificate, because the env var is parsed with
Boolean(process.env.EMAIL_TLS_REJECT_UNAUTHORIZED), which evaluates "0" and "false" to true.

So it appears impossible to set tls.rejectUnauthorized to false via environment variables.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy SplitPro with SMTP login enabled
  2. Use an SMTP relay with a self-signed certificate (for example ProtonMail Bridge)
  3. Set EMAIL_TLS_REJECT_UNAUTHORIZED=0
  4. Try to log in with the email magic link
  5. See the login email fail to send with self-signed certificate

Expected behavior
When EMAIL_TLS_REJECT_UNAUTHORIZED=0 is set, SplitPro should configure Nodemailer with tls.rejectUnauthorized = false and successfully send the magic-link email through SMTP relays using self-signed certificates.

Screenshots
Not applicable.

App version
2.1.1 (NEXT_PUBLIC_APP_VERSION=2.1.1)

Desktop (please complete the following information):

  • OS: Debian 13 server on Docker host
  • Browser: Firefox
  • Version: latest

Smartphone (please complete the following information):
Not tested

Additional context
The relevant code introduced in PR #611 appears to be:

EMAIL_TLS_REJECT_UNAUTHORIZED: process.env.EMAIL_TLS_REJECT_UNAUTHORIZED
  ? Boolean(process.env.EMAIL_TLS_REJECT_UNAUTHORIZED)
  : true

This causes:

  • EMAIL_TLS_REJECT_UNAUTHORIZED=0 -> Boolean("0") -> true
  • EMAIL_TLS_REJECT_UNAUTHORIZED=false -> Boolean("false") -> true

So the variable cannot effectively disable TLS verification.

In our case, the runtime logs still show:

Error sending email [Error: self-signed certificate] { code: 'ESOCKET', command: 'CONN' }
[next-auth][error][SIGNIN_EMAIL_ERROR]

The documentation says:

  • EMAIL_TLS_REJECT_UNAUTHORIZED: Validates TLS certificates by default. Set it to 0 if you have a relay that needs it

So the docs are correct, but the boolean parsing seems broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions