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");
|
||||
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 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;
|
||||
|
||||
let transporter = mail.createTransport({
|
||||
const transporter = mail.createTransport({
|
||||
host: smtpHost,
|
||||
port: smtpPort,
|
||||
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:
|
||||
*to, cc, bcc, *subject, *txt, html. * denotes required */
|
||||
async function send(message) {
|
||||
async function send(message: msgDescriptor): Promise<boolean> {
|
||||
logger.debug("mailServices.send: Message send request received");
|
||||
message.from = fromAddr;
|
||||
message.from = fromAddr || "no-reply@owlboard.info";
|
||||
try {
|
||||
var res = await transporter.sendMail(message);
|
||||
} catch (err) {
|
Loading…
Reference in New Issue
Block a user