I am using node mailer with smtp-pool to sending Mail When I run the app I get this error.
my user and pass and host every thing is right but i face this error.
email.js
const nodemailer = require("nodemailer");
var smtpPool = require('nodemailer-smtp-pool');
const sendEnquiryEmail = function (enquiryData) {
let FromUserName = 'Chat2cars';
nodemailer.createTestAccount((err, account) => {
var transporter = nodemailer.createTransport(smtpPool({
host: 'smtp.gmail.com',
port: 587,
auth: {
user: 'user#gmail.com',
pass: 'mypass'
},
maxConnections: 5,
maxMessages: 10
}));
module.exports = {
sendEnquiryEmail: sendEnquiryEmail
}
And i face this Error
Error: Invalid login: 535 Authentication Credentials Invalid
at SMTPConnection._formatError (D:\CHAT_CAR\Node\node_modules\smtp-connection\lib\smtp-connection.js:528:15)
at SMTPConnection._actionAUTHComplete (D:\CHAT_CAR\Node\node_modules\smtp-connection\lib\smtp-connection.js:1231:30)
at SMTPConnection.<anonymous> (D:\CHAT_CAR\Node\node_modules\smtp-connection\lib\smtp-connection.js:319:22)
at SMTPConnection._processResponse (D:\CHAT_CAR\Node\node_modules\smtp-connection\lib\smtp-connection.js:669:16)
at SMTPConnection._onData (D:\CHAT_CAR\Node\node_modules\smtp-connection\lib\smtp-connection.js:493:10)
at TLSSocket.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at TLSSocket.Readable.push (_stream_readable.js:223:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23) {
code: 'EAUTH',
response: '535 Authentication Credentials Invalid',
responseCode: 535,
command: 'AUTH PLAIN'
}```
Solutions in order of likelihood to help.
Double check you have the correct password 😊
Check if the user has 2fa enabled if so you will need an apps password
Check your Captcha loc
Look into Xoauth2
Related
const nodemailer = require("nodemailer");
require("dotenv").config();
const smtpTransport = nodemailer.createTransport({
host: "mail.ibendouma.com",
port: 465,
secure: true,
auth: {
user: process.env.USER,
pass: process.env.SECRET,
},
});
async function run() {
let sendResult = await smtpTransport
.sendMail({
from: "'iBendouma' <service#ibendouma.com>",
to: "tipox1254#gmail.com",
subject: "Hello from iBendouma",
text: "copier le code et verifier votre identité",
})
.then((res) => console.log(res))
.catch((err) => console.log(err));
console.log(sendResult);
}
run().catch((error) => console.log(error));
Error: Missing credentials for "PLAIN"
at SMTPConnection._formatError (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:787:19)
at SMTPConnection.login (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:441:38)
at C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-transport\index.js:272:32
at SMTPConnection. (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:211:17)
at Object.onceWrapper (events.js:519:28)
at SMTPConnection.emit (events.js:400:28)
at SMTPConnection._actionEHLO (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:1322:14)
at SMTPConnection._processResponse (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:950:20)
at SMTPConnection._onData (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:752:14)
at TLSSocket.SMTPConnection._onSocketData (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib
msypro#Msypro MINGW64 ~/Desktop/test (master)
$ node app.js
Error: Missing credentials for "PLAIN"
at SMTPConnection._formatError (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:787:19)
at SMTPConnection.login (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:441:38)
at C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-transport\index.js:272:32
at SMTPConnection. (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:211:17)
at Object.onceWrapper (events.js:519:28)
at SMTPConnection.emit (events.js:400:28)
at SMTPConnection._actionEHLO (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:1322:14)
at SMTPConnection._processResponse (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:950:20)
at SMTPConnection._onData (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:752:14)
at TLSSocket.SMTPConnection._onSocketData (C:\Users\msypro\Desktop\test\node_modules\nodemailer\lib\smtp-connection\index.js:191:44) {
code: 'EAUTH',
command: 'API'
}
undefined
This error Error: Missing credentials for "PLAIN" at SMTPConnection._formatError occurs when your credentials are missing. First thing you can do is to check whether the env file is specified properly in the code. You have to make sure that your index.js or server.js (or the name of your nodemailer code file) is in the same directory as env file.
If the above is all correct then try adding quotes around your env variable like below.
auth: {
user: `${process.env.USER}`,
pass: `${process.env.SECRET}`,
},
Your auth field have to look like this.
auth: {
user: "someone#gmail.com",
pass: "somesecretpass",
},
Hope this worked!
I have an Azure Ubuntu 18.04 server with Node v12.13.1, my local machine is Windows 10 and node v10.16.0.
When I run on my local computer there is no issue with Nodemailer sending the email, it sends and quickly appears in my email.
However when it is run on my Azure server, I get the following error.
Error: Invalid login: 535 5.7.3 Authentication unsuccessful [BY5PR16CA0034.nampr d16.prod.outlook.com]
at SMTPConnection._formatError (/home/user/EMR/node_modules/nodemailer/l ib/smtp-connection/index.js:784:19)
at SMTPConnection._actionAUTHComplete (/home/user/EMR/node_modules/nodem ailer/lib/smtp-connection/index.js:1523:34)
at SMTPConnection.<anonymous> (/home/user/EMR/node_modules/nodemailer/li b/smtp-connection/index.js:1481:18)
at SMTPConnection._processResponse (/home/user/EMR/node_modules/nodemail er/lib/smtp-connection/index.js:942:20)
at SMTPConnection._onData (/home/user/EMR/node_modules/nodemailer/lib/sm tp-connection/index.js:749:14)
at TLSSocket.SMTPConnection._onSocketData (/home/user/EMR/node_modules/n odemailer/lib/smtp-connection/index.js:195:44)
at TLSSocket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at TLSSocket.Readable.push (_stream_readable.js:224:10) {
code: 'EAUTH',
response: '535 5.7.3 Authentication unsuccessful [BY5PR16CA0034.namprd16.prod. outlook.com]',
responseCode: 535,
command: 'AUTH LOGIN'
}
Here is the code for running Nodemailer on my node.js server:
let transport = nodemailer.createTransport({
service: "Outlook365",
auth: {
user: process.env.USER,
pass: process.env.PASS
},
tls:{
rejectUnauthorized: false
}
})
let message = {
from: '"Name Apps" <nameapps#name.org>',
to: item.email,
subject: subjectText,
html: `<b>HTML message</b>`
};
transport.sendMail(message, function(err, info) {
if (err) {
console.log(err)
} else {
console.log(info);
}
});
So i have the following codes:
const nodemailer = require("nodemailer");
const mailer = {
service: "gmail",
auth: {
type: "OAuth2",
user: "mailtester123123123#gmail.com",
clientId: "123123123123123123123123123123.apps.googleusercontent.com",
clientSecret: "krW123123123123123123RqEnS",
refreshToken: "1/SM-7f31231231231231231231231231231231231231231231231UzH",
accessToken: "ya29.1234568791231324564897894231324564697897ss3Ggi-TkWO4HSIZBqHiLpoIkT7H_Sgii4RQxyVJ0QjIfjKB5zk"
}
}
const transporter = nodemailer.createTransport(mailer);
transporter.sendMail({
to: "mailtester123123123#windowslive.com",
subject: "test",
text: "test"
});
But when i try to send email, it always give error as follow: Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials f67-v6sm75536287pfe.75 - gsmtp
This is the full trace:
(node:25324) UnhandledPromiseRejectionWarning: Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials f67-v6sm75536287pfe.75 - gsmtp
at SMTPConnection._formatError (D:\Sources\NodeJS\test\node_modules\nodemailer\lib\smtp-connection\index.js:606:19)
at SMTPConnection._actionAUTHComplete (D:\Sources\NodeJS\test\node_modules\nodemailer\lib\smtp-connection\index.js:1335:34)
at SMTPConnection._responseActions.push.str (D:\Sources\NodeJS\test\node_modules\nodemailer\lib\smtp-connection\index.js:1314:26)
at SMTPConnection._processResponse (D:\Sources\NodeJS\test\node_modules\nodemailer\lib\smtp-connection\index.js:762:20)
at SMTPConnection._onData (D:\Sources\NodeJS\test\node_modules\nodemailer\lib\smtp-connection\index.js:558:14)
at TLSSocket._socket.on.chunk (D:\Sources\NodeJS\test\node_modules\nodemailer\lib\smtp-connection\index.js:510:47)
at TLSSocket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at TLSSocket.Readable.push (_stream_readable.js:219:10)
Any idea what happened and how to fix this? Thank you.
This error occurs when you are trying to access Google account and forget to switch on Google less security option. Do following changes:
https://myaccount.google.com/lesssecureapps?utm_source=google-account&utm_medium=web
I had this error and my mistake was that I was trying to give only this permission:
"https://www.googleapis.com/auth/gmail.send"
I fixed it by giving the full permissions:
"https://mail.google.com/"
I'm talking about the scopes used to generate the tokens on https://developers.google.com/oauthplayground/
I am trying to connect to a microsoft mail server, with node.js nodemailer module. But I get an error.
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: 'mysmtp.server.com',
port: 25,
secure: false, // true for 465, false for other ports
requireTLS: true,
ignoreTLS: false,
tls : {
rejectUnauthorized: false
},
authMethod: 'LOGIN',
auth: {
type: 'login',
user: 'account#domain.com', // generated ethereal user
pass: 'password' // generated ethereal password
}
});
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log('Server is ready to take our messages');
}
});
ERROR:
{ Error: Invalid login: 504 5.7.4 Unrecognized authentication type
at SMTPConnection._formatError (C:\Users\user\Desktop\mail\node_modules\
nodemailer\lib\smtp-connection\index.js:577:19)
at SMTPConnection._actionAUTHComplete (C:\Users\user\Desktop\mail\node_m
odules\nodemailer\lib\smtp-connection\index.js:1306:34)
at SMTPConnection._responseActions.push.str (C:\Users\user\Desktop\mail\
node_modules\nodemailer\lib\smtp-connection\index.js:349:26)
at SMTPConnection._processResponse (C:\Users\user\Desktop\mail\node_modu
les\nodemailer\lib\smtp-connection\index.js:733:20)
at SMTPConnection._onData (C:\Users\user\Desktop\mail\node_modules\nodem
ailer\lib\smtp-connection\index.js:529:14)
at TLSSocket._socket.on.chunk (C:\Users\user\Desktop\mail\node_modules\n
odemailer\lib\smtp-connection\index.js:680:51)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
code: 'EAUTH',
response: '504 5.7.4 Unrecognized authentication type',
responseCode: 504,
command: 'AUTH PLAIN' }
Does anyone know what is wrong?
Thanks
I'm trying to set up nodemailer for an app I'm creating. I'm receiving an error when I try and run the code.
This is my setup:
const nodemailer = require("nodemailer");
const xoauth2 = require("xoauth2");
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
xoauth2: xoauth2.createXOAuth2Generator({
user: '****#gmail.com',
clientId: '*******************************',
clientSecret: '*****************************',
refreshToken: '*****************************'
})
}
});
var mailOptions = {
from: 'Dave <*******#gmail.com>',
to: '*******#gmail.com',
subject: 'Nodemailer test',
text: 'Hello world'
}
transporter.sendMail(mailOptions, function(err, res) {
if (err) {
console.log(err);
} else {
console.log('Email sent');
}
})
Obviously, I've double checked my client ID, secret and refresh token. But I get the following error:
{ Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials y22sm6749013wry.51 - gsmtp
at SMTPConnection._formatError (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/index.j s:557:19)
at SMTPConnection._actionAUTHComplete (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/ index.js:1248:34)
at SMTPConnection._responseActions.push.str (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-conn ection/index.js:340:26)
at SMTPConnection._processResponse (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/ind ex.js:706:20)
at SMTPConnection._onData (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/index.js:5 09:14)
at TLSSocket._socket.on.chunk (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp- connection/index .js:461:47)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
at TLSWrap.onread (net.js:551:20)
code: 'EAUTH',
response: '535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCrede ntials y22sm6749013wry.51 - gsmtp',
responseCode: 535,
command: 'AUTH PLAIN' }
This is the first time I've tried using nodemailer and I feel I'm obviously missing a key piece here but not sure what.
New error when using real email and password:
{ Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbvZ
534-5.7.14 vX8SWYwnciMLBvsoC9zLFxi_9pKu2juDkWdPY4cJngQct2L0qjKFr3aF_SlAVCV816xj-8
534-5.7.14 eC36n8fZzITno-GnJdvwRSf6eIXfeU_ohzp07tc4S3LA0x2k9xPRwAjMlsWfNoa1Iz2GwX
534-5.7.14 AyBKjwT8nmD-wpNNK5J_bN9F3OI56XFAfw0NmjxKnUfhHXPoTs0sGCc6eRn_9hgYp2TyFe
534-5.7.14 MAd2gvxDCVp5O9V-yuGa9nrch8ey4> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 f135sm7148225wmd.7 - gsmtp
at SMTPConnection._formatError (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp- connection/index.js:557:19)
at SMTPConnection._actionAUTHComplete (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp- connection/index.js:1248:34)
at SMTPConnection._responseActions.push.str (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/index.js:340:26)
at SMTPConnection._processResponse (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/index.js:706:20)
at SMTPConnection._onData (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/index.js:509:14)
at TLSSocket._socket.on.chunk (/home/ubuntu/workspace/NUFC/NUFC_Blogv1.2/node_modules/nodemailer/lib/smtp-connection/index.js:461:47)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
at TLSWrap.onread (net.js:551:20)
code: 'EAUTH',
response: '534-5.7.14 Please log in via your web browser and\n534-5.7.14 then try again.\n534-5.7.14 Learn more at\n534 5.7.14 https://support.google.com/mail/answer/78754 f135sm7148225wmd.7 - gsmtp',
responseCode: 534,
command: 'AUTH PLAIN' }
You need to set up the transporter differently, using the actual email and password of a real Google Account.
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'somerealemailaddress#gmail.com', //email address to send from
pass: 'somerealemailpassword' //the actual password for that account
}
});
Similar question
Sample code: OAuth2 in Nodemailer
var email_smtp = nodemailer.createTransport({
host: "smtp.gmail.com",
auth: {
type: "OAuth2",
user: "youremail#gmail.com",
clientId: "CLIENT_ID_HERE",
clientSecret: "CLIENT_SECRET_HERE",
refreshToken: "REFRESH_TOKEN_HERE"
}
});
const xoauth2 = require("xoauth2");
Actually in my case i didn't make use of the above code which i have mentioned and yet it worked fine...Just changed the google settings from the link sent in the error and it was fine.
But i get the error especially when i try to use yahoo as the service provider instead of google.I have attached a screenshot of the error which i get for your reference.
The error which i get while using yahoo as service provider
I can see and easy way in other post. I only click accounts.google.com/DisplayUnlockCaptcha
from; Nodemailer with Gmail service not working on heroku