简体   繁体   中英

i am trying to send email through nodemailer, i have permitted my google account for less secure apps, still getiing error

I'm trying to send email using nodemailer and below is my code for that...

 require('dotenv').config();

const nodemailer=require('nodemailer');

// step 1
let transporter=nodemailer.createTransport({
    service: 'gmail',
    auth:{
        user: process.env.EMAIL,
        pass: process.env.PASSWORD
    }
});

let mailOptions={
  from: 'abc@gmail.com',
  to: 'mrinal.annand@gmail.com',
  subject: 'Testing and Testing',
  text: 'yes,it works'
};

transporter.sendMail(mailOptions,function(err,data){
    if(err)console.log('Error Occurs',err);
    else console.log('Message sent!!');
})

i am getting this much long error, what i'm doing wrong here. why it is saying username and password not accepted,both my mails are valid and working, password i have given arbitrarily..

Error Occurs 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 x19sm2827077pgk.37 - 
gsmtp
    at SMTPConnection._formatError (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:784:19)
    at SMTPConnection._actionAUTHComplete (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:1536:34)
    at SMTPConnection.<anonymous> (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:540:26)
    at SMTPConnection._processResponse (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:947:20)
    at SMTPConnection._onData (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:749:14)
    at SMTPConnection._actionAUTHComplete (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:1536:34)
    at SMTPConnection.<anonymous> (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:540:26)
    at SMTPConnection._processResponse (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:947:20)
    at SMTPConnection._onData (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:749:14)
    at TLSSocket.SMTPConnection._onSocketData (C:\Users\91725\Desktop\sending_mail\node_modules\nodemailer\lib\smtp-connection\index.js:189:44)
    at TLSSocket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10) {
  code: 'EAUTH',
  response: '535-5.7.8 Username and Password not accepted. Learn more at\n' +     
    '535 5.7.8  https://support.google.com/mail/?p=BadCredentials x19sm2827077pgk.37 - gsmtp',
  responseCode: 535,
  command: 'AUTH PLAIN'
}

显然电子邮件的用户名和密码是错误的,您应该尝试使用这些凭据复制粘贴登录

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM