backend/src/services/mail.services.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

const log = require('../utils/log.utils')
const fs = require('fs')
const mail = require('node-mailer'); //>> Probs wrong
2023-04-01 15:09:29 +01:00
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
2023-04-01 15:11:26 +01:00
// The 'secure' option is not optional to ensure it is not accidentally omitted
2023-04-01 15:09:29 +01:00
const options = {
host: smtpHost,
port: smtpPort,
secure: true,
auth: {
user: smtpUser,
pass: smtpPass
}
}
2023-04-01 15:11:26 +01:00
let transporter = mail.createTransport(options)
2023-04-01 15:09:29 +01:00
async function sendTest(to, subject, plaintext, html) {
log.out(`mailServices.sendTest: Sending test message to: ${to}, subject: ${subject}`, "info")
// Send test mail message
2023-04-01 15:09:29 +01:00
let res = await transporter.sendMail({
from: fromAdrr,
to: to,
subject: subject,
text: plaintext,
html: html
});
return;
}
async function sendRegister() {
return;
}
async function sendAlert() {
return;
2023-04-01 15:09:29 +01:00
}
module.exports = {
sendTest,
sendRegister,
sendAlert
}