4

Nodemailer was working correctly for a few months with exactly the same configuration.

var smtpTransport = nodemailer.createTransport({ service: "Zoho", auth: { user: environment.smtp.email, password: environment.smtp.password }, secure: false, tls: { rejectUnauthorized: false } });

var mailOptions = { from: environment.smtp.email, to: 'some@email.com', subject: 'Subject', html: "Mail content here." }

smtpTransport.sendMail(mailOptions, function(error, response){ console.log(error) });

It throw " Missing credentials for "PLAIN" ". I have used this config in many places in the app and now it throw this error everywhere. But was working well when I have write the code first time.

"nodemailer": "^4.0.1"

Stepan Rafael
  • 365
  • 2
  • 4
  • 13

2 Answers2

2

Here is the config settings. The 'host' field was missing and it seems to be mandatory in the Nodemailer V3 and above.

https://nodemailer.com/smtp/

var smtpTransport = nodemailer.createTransport({ host: "smtp.zoho.com", service: "Zoho", port: 25, secure: false, auth: { user: 'some@email.com', pass: "123456" }, tls: { rejectUnauthorized: false } });

Stepan Rafael
  • 365
  • 2
  • 4
  • 13
1

You may be lacking the credentials. If you are getting your credentials from an .env then you may want to use the dotenv library to fetch them.

var dotenv = require("dotenv")
dotenv.config()

var smtpTransport = nodemailer.createTransport({
    service: "Gmail",
    port: 465,
    auth: {
      user: process.env.GMAIL_USERNAME, 
      pass: process.env.GMAIL_PASSWORD, 
    },
  })

If you are using a remote service to host your server then you may want to see if they have requirements for .env variables. Some services like Vericel will inject .env variables before launching your server.

Isaac Pak
  • 4,467
  • 3
  • 42
  • 48