Initial SeConectai briefing system
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
import nodemailer from "nodemailer";
|
||||
|
||||
type MailOptions = {
|
||||
to: string;
|
||||
subject: string;
|
||||
text: string;
|
||||
};
|
||||
|
||||
export async function sendMail({ to, subject, text }: MailOptions) {
|
||||
const host = process.env.SMTP_HOST;
|
||||
const port = Number(process.env.SMTP_PORT ?? 587);
|
||||
const user = process.env.SMTP_USER;
|
||||
const pass = process.env.SMTP_PASS;
|
||||
const from = process.env.SMTP_FROM;
|
||||
|
||||
if (!host || !from) {
|
||||
return;
|
||||
}
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host,
|
||||
port,
|
||||
secure: port === 465,
|
||||
auth: user && pass ? { user, pass } : undefined
|
||||
});
|
||||
|
||||
await transporter.sendMail({
|
||||
to,
|
||||
from,
|
||||
subject,
|
||||
text
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user