Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

2.4K
Visualizações
Node.js nodemailer error - wrong version number/invalid greeting

I have a big problem with setting up the nodemailer on my node.js server. Tried everthing I found on the internet but nothing works. The only thing that was easy to setup was the gmail service. but unfortunately I cannot use that one.

With secure set to true, i get an ssl error with the reason wrong version code.

[Error: 22468:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
] {
  library: 'SSL routines',
  function: 'ssl3_get_record',
  reason: 'wrong version number',
  code: 'ESOCKET',
  command: 'CONN'
}

But when I try to set secure to false, then I get an invalid greeting error.

Error: Invalid greeting. response=* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2016 Double Precision, Inc.  See COPYING for distribution information.: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2016 Double Precision, Inc.  See COPYING for distribution information.
    at SMTPConnection._actionGreeting (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:1189:27)
    at SMTPConnection._processResponse (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:932:20)
    at SMTPConnection._onData (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:739:14)
    at Socket.SMTPConnection._onSocketData (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:189:44)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:284:9)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  code: 'EPROTOCOL',
  response: '* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2016 Double Precision, Inc.  See COPYING for distribution information.',
  command: 'CONN'
}

My code is the following:

const transporter = nodemailer.createTransport({
  host: process.env.MAIL_HOST, // mx.example.com
  port: process.env.MAIL_PORT, // 143
  secure: true,
  auth: {
    user: process.env.MAIL_ADDRESS,
    pass: process.env.MAIL_PWD
  }
})

I checked the credentials a thousand time, they are definetly not the problem.

Hope anyone can help me. Thanks in advance.

over 4 years ago · Santiago Trujillo
4 Respostas
Responde à pergunta

0

Refering to this issue mentioned here: https://github.com/andris9/Nodemailer/issues/165

See if this helps, adding the tls.ciphers option to use SSLv3:

const transport = nodemailer.createTransport({
    host: process.env.MAIL_HOST, // mx.example.com
    port: process.env.MAIL_PORT, // 143
    secureConnection: false, // TLS requires secureConnection to be false
    auth: {
        user: process.env.MAIL_ADDRESS,
        pass: process.env.MAIL_PWD
    },
    tls: {
        ciphers:'SSLv3'
    }
});

For Outlook365, this should work:

service: "Outlook365",
auth: {
   user: '[YOUR_O365_EMAIL]',
   pass: '[YOUR_O365_PASSWORD]'
}, 

Refer here: https://stackoverflow.com/a/37725123/9360885

If you're using HotMail, then remove host and port, and just add service: "hotmail".

over 4 years ago · Santiago Trujillo Relatório

0

use

secure: false, // true for 465, false for other ports

Example from nodemailer docs:

let transporter = nodemailer.createTransport({
    host: 'smtp.ethereal.email',
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
        user: account.user, // generated ethereal user
        pass: account.pass  // generated ethereal password
    }
});

source: nodemailer examples

over 4 years ago · Santiago Trujillo Relatório

0

If you are still receiving the issue, fix by inputting this into your browser manually while logged in.

https://accounts.google.com/DisplayUnlockCaptcha

over 4 years ago · Santiago Trujillo Relatório

0

I used port 465 with Gmail and that worked. Got the "wrong version number" error with 587. Example below is for a GCP service account in a Cloud Function.

  const transporter = nodemailer.createTransport({
    host: "smtp.gmail.com",
    port: 465,
    secure: true,
    auth: {
      type: "OAuth2",
      user: process.env.GMAIL_ADDRESS,
      serviceClient: process.env.CLIENT_ID,
      privateKey: process.env.PRIVATE_KEY.replace(/\\n/g, "\n"),
    },
  });
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda