diff --git a/helpers/mail.ts b/helpers/mail.ts index 37facdd..3da479a 100644 --- a/helpers/mail.ts +++ b/helpers/mail.ts @@ -1,15 +1,18 @@ const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY +const ADMIN_EMAIL = process.env.ADMIN_EMAIL +const FROM_EMAIL = process.env.FROM_EMAIL const SENDGRID_URL = 'https://api.sendgrid.com/v3/mail/send' -// TODO: move to env -const BOOKING_ADMIN_EMAIL = 'tomru@mail.id0.link' -const FROM_EMAIL = 'pfadibussle@mail.id0.link' if (!SENDGRID_API_KEY) { throw new Error('NO SENDGRID_API_KEY set!') } -if (!SENDGRID_API_KEY) { - throw new Error('NO SENDGRID_API_KEY set!') +if (!ADMIN_EMAIL) { + throw new Error('No ADMIN_EMAIL set!') +} + +if (!FROM_EMAIL) { + throw new Error('No FROM_EMAIL set!') } async function sendMail(data: object) { @@ -40,7 +43,7 @@ export async function sendReceivedBookingMail(booking: { uuid: string }) { const data = { personalizations: [ { - to: [{ email: BOOKING_ADMIN_EMAIL }], + to: [{ email: ADMIN_EMAIL }], }, ], from: { email: FROM_EMAIL },