send mail 2c nodemailer

Solutions on MaxInterview for send mail 2c nodemailer by the best coders in the world

showing results for - "send mail 2c nodemailer"
Camila
23 Mar 2017
1import nodemailer from "nodemailer";
2
3const yourEmail = "yourEmail@gmail.com";
4const yourPass = "yourEmailPasswrd";
5const mailHost = "smpt.gmail.com";
6const mailPort = 587;
7const senderEmail = "senderEmail@gmail.com"
8
9/**
10 * Send mail
11 * @param {string} to 
12 * @param {string} subject 
13 * @param {string[html]} htmlContent 
14 * @returns 
15 */
16const sendMail = (to, subject, htmlContent) => {
17  let transporter = nodemailer.createTransport({
18    host: mailHost,
19    port: mailPort,
20    secure: false, // use SSL - TLS
21    auth: {
22      user: yourEmail,
23      pass: yourPass,
24    },
25  });
26  let mailOptions = {
27    from: senderEmail,
28    to: to,
29    subject: subject,
30    html: htmlContent,
31  };
32  return transporter.sendMail(mailOptions); // promise
33};
34
35export default sendMail;
36
37
38
39