/** * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { createTransport } from "nodemailer"; const mailer = createTransport({ auth: { pass: process.env.EMAIL_PASS, user: "noreply@nhcarrigan.com", }, host: "mail.nhcarrigan.com", port: 465, secure: true, }); /** * Sends an email to Naomi when a form is submitted. * @param formName - A SINGULAR, NOT PLURAL, name representing the form. * @param formData - The data submitted in the form. */ export const sendMail = async( formName: string, formData: Record, ): Promise => { const text = Object.entries(formData). map(([ key, value ]) => { return `${key}: ${String(value)}`; }). join("\n"); await mailer.sendMail({ from: "noreply@nhcarrigan.com", subject: `New ${formName} submission!`, text: text, to: "naomi@nhcarrigan.com", }); };