Horje
npm install nodemailer Code Example
npm install nodemailer
npm i nodemailer
nodemailer, mailer, nodemailer npm
import nodemailer from "nodemailer";

const yourEmail = "yourEmail@gmail.com";
const yourPass = "yourEmailPasswrd";
const mailHost = "smpt.gmail.com";
const mailPort = 587;
const senderEmail = "senderEmail@gmail.com"

/**
 * 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;







Shell

Related
firebase deploy only hosting command Code Example firebase deploy only hosting command Code Example
install spotify ubuntu Code Example install spotify ubuntu Code Example
react router dom with typescript Code Example react router dom with typescript Code Example
Python plot graph in bash Code Example Python plot graph in bash Code Example
yum add proxy Code Example yum add proxy Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12