Nodemailer (email-templates) not sending email to google gmail in express Node.js app

22 Views Asked by At

Emails are sending to everything but "@gmail". Not sure why, seems this is a common problem after google removed trust 3rd party. Here is my code:

const sendMail = async (to) => {
  const Email = require("email-templates");
  const email = new Email({
    message: {
      from: "",
      to: to,
      subject: "Detail Added ",
      text: `insert text here`,
      html: `<p>insert text here</p>`,
    },
    send: true,
    transport: {
      host: "",
      port: 465,
      ssl: true,
      tls: true,
      auth: {
        user: "", // your Mailtrap username
        pass: "", //your Mailtrap password
      },
    },
  });

  await email.send().then(console.log).catch(console.error);
};

Took out the host and such in here for privacy reasons. Does the general structure look fine ? I have tried a couple solutions, one being adding 'name' field in the transport. No luck. App is sending from a the server the site is hosted on. Not using personal email to send. No errors thrown.

0

There are 0 best solutions below