Back

[SOLVED] SSL error when sending email with nodemailer

  • 0
  • Functions
Philipp
17 Jan, 2024, 12:10

when sending a mail (nodemailer) with secure set to true:

TypeScript
    const transporter = nodemailer.createTransport({
        host: process.env.SMTP_SERVER_HOST,
        port: process.env.SMTP_SERVER_PORT,
        secure: true,
        auth: {
            user: process.env.SMTP_USERNAME,
            pass: process.env.SMTP_PASSWORD,
        },
    });

my appwrite function exits with Error: 139628785929072:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332: sending the mail with secure turned off works without issues. do you have any fix for sending the mail with secure turned on?

TL;DR
Title: [SOLVED] SSL error when sending email with nodemailer In this support thread, the developer is encountering an SSL error when sending email with nodemailer. They are using a port that does not support TLS and are self-hosting their SMTP server. The solution is to change the port to one that supports TLS or to use a TLS version that is supported by the server. By changing the configuration to use a port that supports TLS or by turning off the secure option, the developer was able to send the mail without any issues.
D5
17 Jan, 2024, 12:11

This is cloud or self-hosted?

Philipp
17 Jan, 2024, 12:11

the latter

D5
17 Jan, 2024, 12:13

Are you using TLS ports?

D5
17 Jan, 2024, 12:14

There should be ports from your provider to use without TLS and others to use with TLS. This looks like you're using a port that doesn't supports TLS by your provider

Philipp
17 Jan, 2024, 12:16

im running appwrite behind a reverse proxy and the traffic goes over https to the http port of appwrite

D5
17 Jan, 2024, 12:19

Oh, I see. But you're self-hosting the SMTP server?

Philipp
17 Jan, 2024, 12:19

nope

D5
17 Jan, 2024, 12:28

No idea then. From what I'm seeing on Google, looks like others users solved it by changing ports but also others solved it by changing TLS version

Philipp
17 Jan, 2024, 12:32

found my issue:

Philipp
17 Jan, 2024, 12:33

this is from the node mailer docs: secure – if true the connection will use TLS when connecting to server. If false (the default) then TLS is used if server supports the STARTTLS extension. In most cases set this value to true if you are connecting to port 465. For port 587 or 25 keep it false

my port for smpt is indeed 587

Philipp
17 Jan, 2024, 12:33

and uses STARTTLS

D5
17 Jan, 2024, 12:33

I see. Hope that solves the issue

D5
17 Jan, 2024, 12:34

I supposed it was related to some config related to ports

Philipp
17 Jan, 2024, 12:34

i also thought so, thanks for the help

D5
17 Jan, 2024, 12:35

Tell me if that's the final solution and it works

Philipp
17 Jan, 2024, 12:38

seems like it

Philipp
17 Jan, 2024, 12:38

[SOLVED] SSL error when sending email with nodemailer

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more