Files
sign/packages/lib/mail/sendMail.ts

25 lines
556 B
TypeScript
Raw Normal View History

2023-01-26 16:20:48 +01:00
import nodemailer from "nodemailer";
import nodemailerSendgrid from "nodemailer-sendgrid";
export const sendMail = async (
to: string,
subject: string,
htmlFormattedMessage: string
) => {
if (!process.env.SENDGRID_API_KEY)
throw new Error("Sendgrid API Key not set.");
const transport = nodemailer.createTransport(
nodemailerSendgrid({
apiKey: process.env.SENDGRID_API_KEY || "",
})
);
await transport.sendMail({
2023-01-27 18:15:41 +01:00
from: process.env.MAIL_FROM,
2023-01-26 16:20:48 +01:00
to: to,
subject: subject,
html: htmlFormattedMessage,
});
};