orliesaurus/nodemailer-mailgun-transport

createTransport for each email?

Closed this issue · 1 comments

Do I need to create the transport for each email I want to send or can I have this just outside the sendEmail function?

const transporter = nodemailer.createTransport(mg(auth));

const sendEmail = ({htmlBody, subject, email}) => {
  const mailOptions = {from: `"Super user" <${process.env.PARSE_SENDER_EMAIL}>`,to: email, subject, html: htmlBody };

//outside or inisde?
  const transporter = nodemailer.createTransport(mg(auth));

  transporter.sendMail(mailOptions, (error, info) => {
    if(error) console.log(error.message);
    else console.log(`Message sent: ${email},`, info);
  });
};

this is running on a node.js server

outside