+ Renamed the mail model and worked some more on it

This commit is contained in:
kato 2021-08-21 01:56:37 +03:00
parent a9ef1b64ee
commit 41a20438bc
2 changed files with 39 additions and 9 deletions

39
src/models/MailModel.ts Normal file
View File

@ -0,0 +1,39 @@
import {getConfig} from "../helper/config";
import nodemailer from "nodemailer";
const config = getConfig();
/**
* Get the instance of the transporter
* @returns A transporter instance for sending out emails
*/
function getTransporter() : nodemailer.Transporter {
// Generate the transporter
const transporter = nodemailer.createTransport({
host: config?.smtp.host,
auth: {
user: config?.smtp.username,
pass: config?.smtp.password,
}
});
// Return the transporter
return transporter;
}
export async function sendMail(mailContent: string, toAddress: string, ccAddresses?: Array<string>) {
// Get the transporter
const transporter = getTransporter();
await new Promise((_r, _e) => {
transporter.sendMail({
}, (err, info) => {
})
})
transporter.close();
}

View File

@ -1,9 +0,0 @@
import nodemailer from "nodemailer";
function getTransporter() {
}
export function sendMail(mailContent: string, toAddress: string, ccAddresses?: Array<string>) {
}