Port mail.services to TS
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
6d4e862313
commit
ee2cf6e7d5
@ -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) {
|
Loading…
Reference in New Issue
Block a user