newStaffLDB-API #48

Merged
fred.boniface merged 85 commits from newStaffLDB-API into main 2023-10-03 21:35:03 +01:00
Showing only changes of commit ee2cf6e7d5 - Show all commits

View File

@ -1,13 +1,23 @@
const mail = require("nodemailer"); const mail = require("nodemailer");
import { logger } from "../utils/logger.utils"; import { logger } from "../utils/logger.utils";
export interface msgDescriptor {
to: string;
cc?: string;
bcc?: string;
subject: string;
txt: string;
html?: string;
from: string;
}
const fromAddr = process.env.OWL_EML_FROM; const fromAddr = process.env.OWL_EML_FROM;
const smtpUser = process.env.OWL_EML_USER; const smtpUser = process.env.OWL_EML_USER;
const smtpPass = process.env.OWL_EML_PASS; const smtpPass = process.env.OWL_EML_PASS;
const smtpHost = process.env.OWL_EML_HOST; const smtpHost = process.env.OWL_EML_HOST;
const smtpPort = process.env.OWL_EML_PORT; const smtpPort = process.env.OWL_EML_PORT;
let transporter = mail.createTransport({ const transporter = mail.createTransport({
host: smtpHost, host: smtpHost,
port: smtpPort, port: smtpPort,
secure: false, // Must be false for STARTTLS on port 587 which is always secure secure: false, // Must be false for STARTTLS on port 587 which is always secure
@ -17,11 +27,9 @@ let transporter = mail.createTransport({
}, },
}); });
/* 'message' is an object containing string values for: async function send(message: msgDescriptor): Promise<boolean> {
*to, cc, bcc, *subject, *txt, html. * denotes required */
async function send(message) {
logger.debug("mailServices.send: Message send request received"); logger.debug("mailServices.send: Message send request received");
message.from = fromAddr; message.from = fromAddr || "no-reply@owlboard.info";
try { try {
var res = await transporter.sendMail(message); var res = await transporter.sendMail(message);
} catch (err) { } catch (err) {