mirror of
https://github.com/kevin-DL/complete-node-bootcamp.git
synced 2026-01-16 21:24:38 +00:00
Initial commit 🚀
This commit is contained in:
27
4-natours/after-section-12/utils/email.js
Normal file
27
4-natours/after-section-12/utils/email.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user