mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 14:37:13 +01:00
pull emails from env vars
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY
|
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'
|
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) {
|
if (!SENDGRID_API_KEY) {
|
||||||
throw new Error('NO SENDGRID_API_KEY set!')
|
throw new Error('NO SENDGRID_API_KEY set!')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SENDGRID_API_KEY) {
|
if (!ADMIN_EMAIL) {
|
||||||
throw new Error('NO SENDGRID_API_KEY set!')
|
throw new Error('No ADMIN_EMAIL set!')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FROM_EMAIL) {
|
||||||
|
throw new Error('No FROM_EMAIL set!')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendMail(data: object) {
|
async function sendMail(data: object) {
|
||||||
@@ -40,7 +43,7 @@ export async function sendReceivedBookingMail(booking: { uuid: string }) {
|
|||||||
const data = {
|
const data = {
|
||||||
personalizations: [
|
personalizations: [
|
||||||
{
|
{
|
||||||
to: [{ email: BOOKING_ADMIN_EMAIL }],
|
to: [{ email: ADMIN_EMAIL }],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
from: { email: FROM_EMAIL },
|
from: { email: FROM_EMAIL },
|
||||||
|
|||||||
Reference in New Issue
Block a user