Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

automated email sending using node js server

let transport = nodemailer.createTransport({
      host: "smtp.gmail.com",
      port: 465,
      secure: true,
      auth: {
        user: process.env.EMAIL_USER,
        pass: process.env.EMAIL_PASS, // here provide the app password you obtained instead of the user password of your google account.
      },
    });

    const mailOptions = {
      from: "from@gmail.com",
      to: "to@gmail.com",
      subject: "Hello from nodemailer",
      text: `${message}`,
      html: `<h1>${message}</h1>`,
    };

    const result = await transport.sendMail(mailOptions); 
// as I am using a async function I am using the promise pattern, but you can also use callback pattern.
Source by github.com #
 
PREVIOUS NEXT
Tagged: #automated #email #sending #node #js #server
ADD COMMENT
Topic
Name
8+2 =