Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Missing credentials for "PLAIN" at SMTPConnection._formatError #1039

Closed
zbisj opened this issue Jul 17, 2019 · 12 comments
Closed

Error: Missing credentials for "PLAIN" at SMTPConnection._formatError #1039

zbisj opened this issue Jul 17, 2019 · 12 comments
Labels

Comments

@zbisj
Copy link

zbisj commented Jul 17, 2019

Hi I am trying to setup nodemailer with gmail and so far I have been following this video:

Here is my code:
`
const nodemailer = require("nodemailer");
const xoauth2 = require('xoauth2');

// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
  service: "gmail",
  auth: {
    xoauth2:  xoauth2.createXOAuth2Generator({
      user: "myemail@gmail.com",
      clientId: 'xxxxxxxxxxxxxxxxx',
      clientSecret: 'xxxxxxxxxxxxxxxxx',
      refreshToken: 'xxxxxxxxxxxxxxxxx'
    })
  }
});

// send mail with defined transport object
let mailOptions = {
  from: '"Fred Foo 👻" <sender@email.com>', // sender address
  to: "receiver@email.com", // receiver address
  subject: "Hello ✔", // Subject line
  text: "Hello world?", // plain text body
  html: "<b>Hello world?</b>" // html body
};

transporter.sendMail(mailOptions, (error, res) => {
  if (error) {
    console.log(error);
  }else {
    console.log("email is sent");
  }
})

`

I am getting this error:
{ Error: Missing credentials for "PLAIN" at SMTPConnection._formatError (/home/xxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:781:19) at SMTPConnection.login (/home/xxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:452:38) at connection.connect (/home/xxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-transport/index.js:271:32) at SMTPConnection.once (/home/xxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:209:17) at Object.onceWrapper (events.js:286:20) at SMTPConnection.emit (events.js:198:13) at SMTPConnection._actionEHLO (/home/xxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:1309:14) at SMTPConnection._processResponse (/home/xxxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:940:20 ) at SMTPConnection._onData (/home/xxxxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js:746:14) at TLSSocket.SMTPConnection._onSocketData (/home/xxxxxxxxx/projects/my-projects/test/node_modules/nodemailer/lib/smtp-connection/index.js :189:46) code: 'EAUTH', command: 'API' }

Version Numbers

os: ubuntu 19.04
node 10.16.0
nodemailer 6.3.0

I do not understand which credentials are missing as I have provided them. I have looked on almost all the articles on this issue and none have helped.

Also a quick question: Is it possible to use nodemailer on just a create-react-app without having to setup a backend for it?

Thanks in advance

@stale
Copy link

stale bot commented Sep 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 15, 2019
@stale stale bot closed this as completed Sep 22, 2019
@tdj03001
Copy link

tdj03001 commented May 6, 2020

Did you ever figure this out? I'm on a deadline and this error has all of a sudden crept into my project. It was running fine and I think the only thing I may have changed between when it was running and now is my google account authentication. Any ideas would be very welcomed!

@dankore
Copy link

dankore commented Jun 23, 2020

For me, it was due to not adding my Gmail password to the .env file.

@ajj-siraj
Copy link

For me, it was due to not adding my Gmail password to the .env file.

I can't believe I just spent 4 hours trying to debug this when this was all it was. I was using a private mail server though not Gmail, but same issue.

@MrFarhan
Copy link

@zbisj try running it locally with NGROK server... it is working fine.

I am also facing same issue, my code is working fine and sending emails, but showing error on heroku.

I am using zoho email server

@Kamrulhasan12345
Copy link

For me, it was occuring while adding no text field in message object

@berenia
Copy link

berenia commented May 3, 2023

Hi guys,
I was able to fix this issue on my end. What I did was this:

  • log the transporter object
  • check the properties and values if its there
  • then I discovered pass value was showing undefined.
  • then I discovered I didn't add it to my environment variable on the server

I hope this is helpful to someone

@kushagra9999
Copy link

Thanks it worked for me .

@killshot13
Copy link

Same issue here. I had rebuilt the dotenv-vault and provided the decryption key to the server, but I had forgotten to update the mail server password in the .env file first. Oops!🤦🏼‍♂️

@devashishroychowdhury
Copy link

Try to use your email password in .env file and run the program again it might fix your issue

@rohitkashyaprk
Copy link

Hi, In the first go try to use pass instead of password in auth field.

@wariszargardev
Copy link

const transporter = nodemailer.createTransport({
    host: process.env.EMAIL_HOST,
    port: process.env.EMAIL_PORT,
    auth: {
        user: process.env.EMAIL_USERNAME,
        pass: process.env.EMAIL_PASSWORD
    }
});

try this one 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests