Nodemailer cannot send message

I have used my 2,gmail account one to send a plan text message to the other one as client. Using nodemailer,nodemailer cannot send the message after making so many attempt. I turn on login from 2step,in gmail setting still cannot send the message please help.
my code snippet

async function handleEMail(req, res, next) {
  var { user } = req;
  const transporter = nodemailer.createTransport({
    host: "",
    port: 465,
    secure: true,
    auth: {
      user: "",
      Password: "ruthtersoor090"
  const mailOption = {
    from: "",
    subject: "sending nodemailer",
    text: "can you see the server mail"
  const plan = transporter.sendMail(mailOption, function(error) {
    res.send("error email to client ");

Hi @route-chris !

I messed around with nodemailer a couple of weeks ago and I also struggled with getting it to work with gmail.

Nodemailer has a lengthy explanation of why gmail is tricky.
Have you tried using other email accounts?

I got mine working with hotmail.

Sidenote: You might consider storing your email information in an env file and just referencing the variable names here

1 Like

If you don’t mind can I have your code snippet ,for only nodemailer. Or may be we have the same code type,

Am considering the Hotmail since all my effort at gmail hit the rock.
And are you suggesting using the email directly from nodemailer could be one of the problem.

Here is my App.js.

I just think for your auth object in the transporter and from key in the mailOption you might feel better storing that sensitive information in an env file.

You will see in my app.js that I am referring to that information in variables.

const momEmail = process.env.MOM_EMAIL;
const jessEmail = process.env.ADMIN_EMAIL;
const jessPassword = process.env.ADMIN_PASSWORD;
1 Like

i appreciate jwilkins, i almost don’t remember that. i mean hiding the secrete. and thanks for the code.

1 Like

You can ignore this line

I hadn’t gotten around to implementing that part of the code yet.

1 Like

sorry do you have idea about this error
Error: Missing credentials for "LOGIN"
in case you will like to refer to the project use this link: Glitch. the error above is what am getting from the console

Hmm… maybe the issue is here.

 auth: {
      user: emailMe,
      password: password.toString()

I think it is supposed to be pass:password.toString()

When I googled the error that issue kept coming up.

Maybe you can try that :woman_shrugging:

1 Like

yeah, i equally google the error but i could understand little that , the node mailer does not pass a number directly, you need to pass it through a string. that is why you see the toString().
I have made the correction you suggested and i think it work. cause this is the message i got from the console :: Error: Invalid login: 535 5.7.3 Authentication unsuccessful []

at SMTPConnection._formatError (/rbd/pnpm-volume/34e924cd-c1b6-43f5-9142-4acf8cf7d4de/node_modules/

at SMTPConnection._actionAUTHComplete (/rbd/pnpm-volume/34e924cd-c1b6-43f5-9142-4acf8cf7d4de/node_modules/

at SMTPConnection.<anonymous> (/rbd/pnpm-volume/34e924cd-c1b6-43f5-9142-4acf8cf7d4de/node_modules/

at SMTPConnection._processResponse (/rbd/pnpm-volume/34e924cd-c1b6-43f5-9142-4acf8cf7d4de/node_modules/

at SMTPConnection._onData (/rbd/pnpm-volume/34e924cd-c1b6-43f5-9142-4acf8cf7d4de/node_modules/

at TLSSocket.SMTPConnection._onSocketData (/rbd/pnpm-volume/34e924cd-c1b6-43f5-9142-4acf8cf7d4de/node_modules/

at TLSSocket.emit (events.js:196:13)

at addChunk (_stream_readable.js:290:12)

at readableAddChunk (_stream_readable.js:271:11)

at TLSSocket.Readable.push (_stream_readable.js:226:10) {

code: ‘EAUTH’,

response: '535 5.7.3 Authentication unsuccessful ’ +


responseCode: 535,

command: ‘AUTH LOGIN’

though am still using gmail. so am going to try using hotmail now , the question were your using both hotmail, or you were sending hotmail against gmail.???
but come to think of it you pass yours without the toString.

Edit: I see you made that change. I missed that part in your message.

Than maybe it is because of google.

I was using hotmail and sending it to a hotmail account.

1 Like

congrats, the message was delivered, but as junk message that is outlook. i have a question like:

  1. How can we deliver the message in the inbox
  2. I dont know but i feel people go for gmail more than any other mail, now how can we send message to gmail .
    Some one suggested you can deactivate secure login from gmail setting , but that is putting the mail at risk if you ask me . can you suggest anothe method??

I didn’t have any issue having message going to the inbox. So I am not sure why yours is going to the junk mail.

Maybe you can try asking on stackoverflow and see if someone has the solution.
You can also dig around the past github issues for nodemailer and see if the answer is in there.

Good luck!

1 Like

I have successful sent to gmail. Follow this steps:
1.turn on your gmail less secure app
2.disabled recapture on you goggle account that is gmail account, in other to login with a new device .
instructions was from stack overflow

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.