const log = require('../utils/log.utils') const fs = require('fs/promises') const mail = require('nodemailer'); //>> 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 // The 'secure' option is set to false as the SMTP server used only supports STARTTLS and will not accept TLS or no encryption const options = { host: smtpHost, port: smtpPort, secure: false, auth: { user: smtpUser, pass: smtpPass } } let transporter = mail.createTransport(options) async function sendTest(to, cc, bcc) { log.out(`mailServices.sendTest: Sending test message to: ${to}`, "info") let tHtml = fs.readFile('mail-templates/test.html', 'utf-8'); let tTxt = fs.readFile('mail-templates/test.txt', 'ascii') // Send test mail message try { var res = await transporter.sendMail({ from: fromAdrr, to: to, cc: cc, bcc: bcc, subject: "Test Message from OwlBoard", text: await tTxt, html: await tHtml }); } catch(err) { log.out(err, "warn") var res = "failed" } return res; } async function sendRegister() { return; } async function sendAlert() { return; } module.exports = { sendTest, sendRegister, sendAlert }