Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

486
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!