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

388
Visualizações
nodemailer not sending email node.js

I have this entire function, which is supposed to send an email, however, it is sending an error:

  var email = req.query.email;
var name = req.query.name;
var trainername = req.query.trainername;
var sessionDate = new Date().toLocaleString();
console.log(email)
console.log(name)
console.log(trainername)
console.log(sessionDate)
    // async..await is not allowed in global scope, must use a wrapper
    async function main() {
      // Generate test SMTP service account from ethereal.email
      // Only needed if you don't have a real mail account for testing
      let testAccount = await nodemailer.createTestAccount();
  
      // create reusable transporter object using the default SMTP transport
      let transporter = nodemailer.createTransport({
        host: "smtp.gmail.com",
        port: 587,
        secure: false, // true for 465, false for other ports
        auth: {
          user: "myemail@gmail.com,
          pass: "1234567890",
        },
      });
  

  
      let supportNumber = Math.random().toString(36).substring(7);
      console.log("support number", supportNumber);
  
      // send mail with defined transport object
      let clientEmail = await transporter.sendMail({
        from: "mm@mm.com", // sender address
        to: "g@rr.com", // list of receivers
        subject: "Today's class conformation", // Subject line
        text:
          "Hi " +
          name +
          ", \n\n Your class with '" + trainername + " has been completed. This message is being sent at: " + sessionDate, // plain text body
      });

  
      console.log("Message sent: %s", clientEmail.messageId);
      // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
  
      // Preview only available when sending through an Ethereal account
      console.log("Preview URL: %s", clientEmail.getTestMessageUrl(info));
      // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
    }
  
    main().catch(console.error);
    res.redirect("/dashboard");

here is the error:

 Error: connect ETIMEDOUT 13.49.22.0:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '13.49.22.0',
  port: 443,
  type: 'FETCH',
  sourceUrl: 'https://api.nodemailer.com/user'
}

but I can't figure out what is wrong with my code! I have used this exact code before. I am assuming it is something wrong with my PORT, but i cannot think of the issue. Does anyone see anything wrong?

about 4 years ago · Juan Pablo Isaza
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