bradtraversy / nodecontactform

Node.js app that uses nodemailer to send emails
178 stars 173 forks source link

Invalid login: 535-5.7.8 Username and Password not accepted. #3

Closed shiladityab24 closed 4 years ago

shiladityab24 commented 4 years ago

facing issue from this line in app.js file:

let transporter = nodemailer.createTransport({ host: "smtp.gmail.com", port: 465, secure: true, // true for 465, false for other ports auth: { user: '****@gmail.com', pass: '*****' }, tls:{ rejectUnauthorized:false } });

and giving an error in the terminal

Server started... { 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 s68sm6561971pjb.38 - gsmtp at SMTPConnection._formatError (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:784:19) at SMTPConnection._actionAUTHComplete (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:1523:34) at SMTPConnection._responseActions.push.str (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:550:26) at SMTPConnection._processResponse (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:942:20) at SMTPConnection._onData (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:749:14) at TLSSocket.SMTPConnection._onSocketData.chunk (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:195:44) at TLSSocket.emit (events.js:198:13) at addChunk (_stream_readable.js:288:12) at readableAddChunk (_stream_readable.js:269:11) at TLSSocket.Readable.push (_stream_readable.js:224:10) 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=BadCredentials s68sm6561971pjb.38 - gsmtp', responseCode: 535, command: 'AUTH PLAIN' }

My email id and password is correct but still facing this error.

AhmedAbdelhak1 commented 4 years ago

-You need to add service: 'gmail'. let transporter = nodemailer.createTransport({ service: 'gmail' host: "smtp.gmail.com", port: 465, secure: true, // true for 465, false for other ports auth: { user: '**@gmail.com', pass: '***' }, tls:{ rejectUnauthorized:false } });

shiladityab24 commented 4 years ago

-You need to add service: 'gmail'. let transporter = nodemailer.createTransport({ service: 'gmail' host: "smtp.gmail.com", port: 465, secure: true, // true for 465, false for other ports auth: { user: '**@gmail.com', pass: '***' }, tls:{ rejectUnauthorized:false } });

Same problem is showing

shiladityab24 commented 4 years ago

Hey, By oauth2 it is working.I have used this format auth: { type: 'OAuth2', user: serverConfig.gmail.client_user, clientId: serverConfig.gmail.client_id, clientSecret: serverConfig.gmail.secret, refreshToken: serverConfig.gmail.refresh_token, accessToken: serverConfig.gmail.access_token, },

shiladityab24 commented 4 years ago

I dont know why it is not working with email and password, anyways from now onwards I have to use oauth for nodemailer