Files
the-biergarten-app/config/sparkpost/sendEmail.ts
Aaron William Po 0d3785ad1a Add environment variable validation and parsing
Adds a validation schema for the application's environment variables using the Zod library. The parsed environment variables are then exported as constants that can be imported throughout the application, replacing the direct use of process.env.
2023-04-07 11:37:30 -04:00

21 lines
446 B
TypeScript

import { SPARKPOST_SENDER_ADDRESS } from '../env';
import client from './client';
interface EmailParams {
address: string;
text: string;
html: string;
subject: string;
}
const sendEmail = async ({ address, text, html, subject }: EmailParams) => {
const from = SPARKPOST_SENDER_ADDRESS;
await client.transmissions.send({
content: { from, html, subject, text },
recipients: [{ address }],
});
};
export default sendEmail;