-1

iam using nodemailer to sent an email but it only working for email not for gmail

// this is config connections

"nodemailer" : { 
         
         "host": "xxx.xxxxx.com",
         "port": 587,
         "secure":true,
        "auth": {
        "user": "myuser.com", 
        "pass": "password"
    } ,
    "tls": {
      "rejectUnauthorized": false,
      "minVersion": "TLSv1"
       },
    "debug":true,
    "logger":true
  },
  "receivingEmail": {
    "feedbackemail" : "abcd@gmailcom",
    "contactemail" : "abcdef@gmail.com"
  }

//nodemailer configurations

const transporter = nodemailer.createTransport((config["nodemailer"]));
      var mailOptions = {
                from: `${config["nodemailer"]["user"]}`,
                to: tomail,
                subject: subject ,
                text: data
              };
              transporter.verify(function(error, success) {
                if (error) {
                  console.log(error,"17");
                } else {
                  console.log("Server is ready to take our messages");
                }
              });

          transporter.sendMail(mailOptions, function(error, info){
            if (error) {
              console.log(error);
            } else {
              console.log('Email sent: ' + info.response);
          } 
        });

here iam sending an email but couldn't able to send gmail accounts Nodemailer 6.1.1 not working with NodeJs >=12 i tried this.. could you suggest me where is the mistake?

Divya rani
  • 1
  • 1
  • 2

1 Answers1

1

You need to make these changes to the gmail account to send an email. Go here and change it ON because Some apps and devices use less secure sign-in technology, which makes your account more vulnerable. You can turn off access for these apps, which we recommend, or turn on access if you want to use them despite the risks.

This thread have some options which you can try and might help if the above solution doesn't work.

Apoorva Chikara
  • 8,277
  • 3
  • 20
  • 35