Answers for "send mail, nodemailer, nodemailer, mailer, nodemailer npm"

0

send mail, nodemailer, nodemailer, mailer, nodemailer npm

import nodemailer from "nodemailer";

const yourEmail = "[email protected]";
const yourPass = "yourEmailPasswrd";
const mailHost = "smpt.gmail.com";
const mailPort = 587;
const senderEmail = "[email protected]"

/**
 * Send mail
 * @param {string} to 
 * @param {string} subject 
 * @param {string[html]} htmlContent 
 * @returns 
 */
const sendMail = (to, subject, htmlContent) => {
  let transporter = nodemailer.createTransport({
    host: mailHost,
    port: mailPort,
    secure: false, // use SSL - TLS
    auth: {
      user: yourEmail,
      pass: yourPass,
    },
  });
  let mailOptions = {
    from: senderEmail,
    to: to,
    subject: subject,
    html: htmlContent,
  };
  return transporter.sendMail(mailOptions); // promise
};

export default sendMail;
Posted by: Guest on October-03-2021

Code answers related to "send mail, nodemailer, nodemailer, mailer, nodemailer npm"

Code answers related to "Javascript"

Browse Popular Code Answers by Language