0

When I was using amazon EC2 free instance, and in my Node API project, I used Nodemailer to sent emails from my GMAIL account, and that was running perfectly without any issue, but not I have moved on to the Amazon lightsail for production, with the same code I can not send email.

I have opened all the ports in lightsail which I had in EC2 instance.

I have tried all other possible ways but it isn't working. I am getting no errors.

This is my code to send email

const mailOptions = {
        from: email.from || emailSettings.auth.user,
        to: email.to,
        subject: email.subject,
        attachments: email.filePath,
        html: email.template
      };
Cœur
  • 37,241
  • 25
  • 195
  • 267
Dhruv Patadia
  • 152
  • 2
  • 10

1 Answers1

1

I found the solution on this thread

Nodemailer - Works locally but not on production

You have to change some of your gmail settings:

Disable Captcha temporarily so you can mail using new server,

https://accounts.google.com/b/0/displayunlockcaptcha

Dhruv Patadia
  • 152
  • 2
  • 10