Files
complete-node-bootcamp/4-natours/after-section-10/utils/email.js
Jonas Schmedtmann 7f81af0ddf Initial commit 🚀
2019-06-13 15:43:15 +01:00

28 lines
642 B
JavaScript

const nodemailer = require('nodemailer');
const sendEmail = async options => {
// 1) Create a transporter
const transporter = nodemailer.createTransport({
host: process.env.EMAIL_HOST,
port: process.env.EMAIL_PORT,
auth: {
user: process.env.EMAIL_USERNAME,
pass: process.env.EMAIL_PASSWORD
}
});
// 2) Define the email options
const mailOptions = {
from: 'Jonas Schmedtmann <hello@jonas.io>',
to: options.email,
subject: options.subject,
text: options.message
// html:
};
// 3) Actually send the email
await transporter.sendMail(mailOptions);
};
module.exports = sendEmail;