“comment utiliser nodemailer” Réponses codées

Envoyer un courrier, 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;



minhchiu

nodemaileur

const nodemailer = require("nodemailer");

let email = ""
let send_to = ""

// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: "", // generated ethereal user
pass: "", // generated ethereal password
},
});


var mailOptions = {
from: email,
to: send_to,
subject: 'Sending Email using Node.js',
text: '<h1>TEST DESH!!</h1>'
};

transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
Maeron Reyes

comment utiliser nodemailer

const transporter = nodeMailer.createTransport({
    host: process.env.SMTP_HOST,
    port: 587,
    secure: false,
    auth: {
      user: process.env.SMTP_MAIL,
      pass: process.env.SMTP_PASSWORD,
    },
  });

  const mailOptions = {
    from: process.env.SMTP_MAIL,
    to: emailUser.email,
    subject: emailUser.subject,
    text: emailUser.message,
  };

  await transporter.sendMail(mailOptions);
Coding is fun

nodemaileur

var smtpTransport = require('nodemailer-smtp-transport');

var transport = nodemailer.createTransport(smtpTransport({
    service: 'gmail',
    auth: {
        user: '[email protected]', // my mail
        pass: 'mypassword'
    }
}));
Joyous Jackal

Réponses similaires à “comment utiliser nodemailer”

Questions similaires à “comment utiliser nodemailer”

Plus de réponses similaires à “comment utiliser nodemailer” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code