Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

npm install nodemailer

npm i nodemailer
Comment

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;



Comment

PREVIOUS NEXT
Code Example
Shell :: how to enable migration in package manager console 
Shell :: docker alpine create user and group 
Shell :: linux version 
Shell :: sdkman install 
Shell :: proc folder 
Shell :: instalar pyqt5 con en mac 
Shell :: how to give all permission to a directory in linux 
Shell :: remove remote git 
Shell :: git push heroku master 
Shell :: venv activate 
Shell :: how to install pg_dump on mac 
Shell :: bash comment 
Shell :: bash check if variable is number 
Shell :: npm ERR! path /usr/local/lib/nodejs/node-v10.15.3-linux-x64/lib/node_modules while installing angular cli 
Shell :: intellij goto line 
Shell :: reset to factory settings fortigate 
Shell :: scp download file 
Shell :: access docker ubuntu terminal 
Shell :: problema hora windows ubuntu 
Shell :: Sticky notes for Linux(Ubuntu) 
Shell :: install neovim ubuntu 
Shell :: install aws cli 
Shell :: gitignroe remove folder 
Shell :: progress bar file.tar.xz extract 
Shell :: ubuntu microphone does not work 
Shell :: install pyramid 
Shell :: bash count character in variable 
Shell :: robotframework seleniumlibrary install 
Shell :: ubuntu shell touch multiple files 
Shell :: how to force push heroku 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =