From 464e470441287572cfda8d95484f781236b9db35 Mon Sep 17 00:00:00 2001 From: piotrruss Date: Mon, 9 Aug 2021 21:36:03 +0200 Subject: init commit --- lib/sendMail.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/sendMail.js (limited to 'lib/sendMail.js') diff --git a/lib/sendMail.js b/lib/sendMail.js new file mode 100644 index 0000000..f50eaf1 --- /dev/null +++ b/lib/sendMail.js @@ -0,0 +1,26 @@ +import nodemailer from 'nodemailer' + +const sendMail = (to, subject, text, html) => { + + const transporter = nodemailer.createTransport({ + port: 465, + host: process.env.MYAPPS_MAIL_SMTP_SERVER, + auth: { + user: process.env.MYAPPS_MAIL_ADDRESS, + pass: process.env.MYAPPS_MAIL_PASSWORD, + }, + secure: true, + }) + + const mailData = { + from: `"Notes App" <${process.env.MYAPPS_MAIL_ADDRESS}>`, + to, + subject, + text, + html, + } + + return transporter.sendMail(mailData) +} + +export default sendMail -- cgit v1.2.3