16 lines
726 B
TypeScript
16 lines
726 B
TypeScript
import sgMail from "@sendgrid/mail";
|
|
|
|
const { CAIRO_BOT_EMAIL: botEmail, CAIRO_SENDGRID_KEY: sendgridApiKey } = process.env;
|
|
|
|
// Configure API Key
|
|
sgMail.setApiKey(sendgridApiKey ?? "");
|
|
if (!botEmail && !!sendgridApiKey) throw Error("Bot Email wasn't defined but API key was!");
|
|
|
|
const from = botEmail ?? "donotreply@dunemask.dev";
|
|
const ignoreMessage = `If you did not sign up for a cairo account, please ignore this email!`;
|
|
|
|
export const sendMessage = (to: string, subject: string, text: string) =>
|
|
sgMail.send({ from, to, subject, text: text + `\n${ignoreMessage}` });
|
|
|
|
export const sendHtml = (to: string, subject: string, html: string) =>
|
|
sgMail.send({ from, to, subject, html: html + `<p>${ignoreMessage}</p>` });
|