Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

488
Vistas
Nodemailer sendMessage() fails with Error: Missing credentials for PLAIN

I am attempting to send an email using Nodemailer and Twilio Sendgrid, following the tutorial here. As far as I can tell I am following the instructions in the tutorial, as well as theNodemailer and Sendgrid documentation. However every time this method is called, the code in the catch block executes, and I get the error Error: Missing credentials for "PLAIN". There are some other posts on Stackoverflow about this error, but nothing that has helped me solved the problem. I've been stuck on this for several hours, and I'd appreciate any insight anyone can offer!

Here is my code:

async function sendEmail(email, code) {
    try{
        const smtpEndpoint = "smtp.sendgrid.net";
        const port = 465;
        const senderAddress = 'Name "contact@mydomain.com"';
        const toAddress = email;
        const smtpUsername = "apikey";
        const smtpPassword = process.env.SG_APIKEY;
        const subject = "Verify your email";

        var body_html = `<!DOCTYPE> 
        <html>
          <body>
            <p>Your authentication code is : </p> <b>${code}</b>
          </body>
        </html>`;

        let transporter = nodemailer.createTransport({
          host: smtpEndpoint,
          port: port,
          secure: true, 
          auth: {
            user: smtpUsername,
            pass: smtpPassword,
          },
          logger: true,
          debug: true,
        });
        
        let mailOptions = {
          from: senderAddress,
          to: toAddress,
          subject: subject,
          html: body_html,
        };

        let info = await transporter.sendMail(mailOptions);
        return { error: false };
    } catch (error) {
    console.error("send-email-error", error);

    return {
      error: true,
      message: "Cannot send email",
    };
  }
}

And here is the log: error log in bash terminal

Thanks!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda