From 062efd940f12d0dbbbadc4c3c39555066a7dbb74 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 1 Apr 2023 15:09:29 +0100 Subject: [PATCH] Beef out mail.services --- src/services/mail.services.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/services/mail.services.js b/src/services/mail.services.js index 56262ee..10dae8b 100644 --- a/src/services/mail.services.js +++ b/src/services/mail.services.js @@ -2,9 +2,34 @@ const log = require('../utils/log.utils') const fs = require('fs') const mail = require('node-mailer'); //>> Probs wrong +const fromAdrr = process.env.OWL_EML_FROM +const smtpUser = process.env.OWL_EML_USER +const smtpPass = process.env.OWL_EML_PASS +const smtpHost = process.env.OWL_EML_HOST +const smtpPort = process.env.OWL_EML_PORT -async function sendTest() { +const options = { + host: smtpHost, + port: smtpPort, + secure: true, + auth: { + user: smtpUser, + pass: smtpPass + } +} + +let transporter = nodemailer.createTransport(options) + +async function sendTest(to, subject, plaintext, html) { + log.out(`mailServices.sendTest: Sending test message to: ${to}, subject: ${subject}`, "info") // Send test mail message + let res = await transporter.sendMail({ + from: fromAdrr, + to: to, + subject: subject, + text: plaintext, + html: html + }); return; } @@ -14,4 +39,10 @@ async function sendRegister() { async function sendAlert() { return; +} + +module.exports = { + sendTest, + sendRegister, + sendAlert } \ No newline at end of file