💬 ♻️ signed mail template

This commit is contained in:
Timur Ercan
2023-02-21 17:42:30 +01:00
parent 12a8a1ddc0
commit 21794a860d
8 changed files with 82 additions and 33 deletions

View File

@ -1,7 +1,16 @@
import { ReadStream } from "fs";
import nodemailer from "nodemailer";
import nodemailerSendgrid from "nodemailer-sendgrid";
export const sendMail = async (to: string, subject: string, body: string) => {
export const sendMail = async (
to: string,
subject: string,
body: string,
attachments: {
filename: string;
content: string | Buffer;
}[] = []
) => {
if (!process.env.SENDGRID_API_KEY)
throw new Error("Sendgrid API Key not set.");
@ -16,6 +25,7 @@ export const sendMail = async (to: string, subject: string, body: string) => {
to: to,
subject: subject,
html: body,
attachments: attachments,
})
.catch((err) => {
throw err;