Send email with nodemailer

Enable these
lesssecure
DisplayUnlockCaptcha

import nodemailer from “nodemailer”;
async function sendEmail(to, subject, text) {
try {
const transport = nodemailer.createTransport({
port: 587,
host: “smtp.gmail.com”,
auth: {


This content originally appeared on DEV Community and was authored by MOHSIN ALI SOOMRO

Enable these
lesssecure
DisplayUnlockCaptcha

import nodemailer from "nodemailer";
async function sendEmail(to, subject, text) {
  try {
    const transport = nodemailer.createTransport({
      port: 587,
      host: "smtp.gmail.com",
      auth: {
        user: "<Your Email>",
        pass: "<Your Password>",
      },
    });
    const option = {
      from: "<Email>",
      to: to,
      subject: subject,
      text: text,
    };
    const result = await transport.sendMail(option);
    console.log("function", { result });
    return result;
  } catch (error) {
    return error;
  }
}


This content originally appeared on DEV Community and was authored by MOHSIN ALI SOOMRO


Print Share Comment Cite Upload Translate Updates
APA

MOHSIN ALI SOOMRO | Sciencx (2022-02-07T08:00:18+00:00) Send email with nodemailer. Retrieved from https://www.scien.cx/2022/02/07/send-email-with-nodemailer/

MLA
" » Send email with nodemailer." MOHSIN ALI SOOMRO | Sciencx - Monday February 7, 2022, https://www.scien.cx/2022/02/07/send-email-with-nodemailer/
HARVARD
MOHSIN ALI SOOMRO | Sciencx Monday February 7, 2022 » Send email with nodemailer., viewed ,<https://www.scien.cx/2022/02/07/send-email-with-nodemailer/>
VANCOUVER
MOHSIN ALI SOOMRO | Sciencx - » Send email with nodemailer. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/07/send-email-with-nodemailer/
CHICAGO
" » Send email with nodemailer." MOHSIN ALI SOOMRO | Sciencx - Accessed . https://www.scien.cx/2022/02/07/send-email-with-nodemailer/
IEEE
" » Send email with nodemailer." MOHSIN ALI SOOMRO | Sciencx [Online]. Available: https://www.scien.cx/2022/02/07/send-email-with-nodemailer/. [Accessed: ]
rf:citation
» Send email with nodemailer | MOHSIN ALI SOOMRO | Sciencx | https://www.scien.cx/2022/02/07/send-email-with-nodemailer/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.