diff --git a/backend/src/index.ts b/backend/src/index.ts index ba8bf0a..739ceb1 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -300,25 +300,34 @@ app.post('/api/events/:slug/rsvp', async (req: Request, res: Response) => { const eventTitle = eventInfo ? eventInfo.title : slug; const eventSlug = eventInfo ? eventInfo.slug : slug; - // Optionally send RSVP confirmation email to admin if EMAIL_USER is set - const adminEmail = process.env.EMAIL_USER; - if (adminEmail) { + // Optionally send RSVP confirmation email to recipients + let recipients: string[] = []; + if (process.env.EMAIL_RECIPIENTS) { + recipients = process.env.EMAIL_RECIPIENTS.split(',').map(addr => addr.trim()).filter(Boolean); + } else if (process.env.EMAIL_USER) { + recipients = [process.env.EMAIL_USER]; + } + if (recipients.length > 0) { try { - await sendRSVPEmail({ - eventTitle, - eventSlug, - name, - attending, - bringingGuests: bringing_guests, - guestCount: guest_count, - guestNames: parsedGuestNames, - itemsBringing: parsedItemsBringing, - otherItems: other_items || '', - to: adminEmail, - }); + for (const to of recipients) { + await sendRSVPEmail({ + eventTitle, + eventSlug, + name, + attending, + bringingGuests: bringing_guests, + guestCount: guest_count, + guestNames: parsedGuestNames, + itemsBringing: parsedItemsBringing, + otherItems: other_items || '', + to, + }); + } } catch (emailErr) { console.error('Error sending RSVP email:', emailErr); } + } else { + console.warn('No email recipients set. Skipping RSVP email notification.'); } // Return the complete RSVP data including the parsed arrays diff --git a/docker-compose.yml b/docker-compose.yml index f1ef5ff..47f8c7a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: - EMAIL_FROM_ADDRESS=your@email.com - EMAIL_SECURE=false - FRONTEND_BASE_URL=https://your-frontend-domain.com + - EMAIL_RECIPIENTS=admin1@email.com,admin2@email.com restart: unless-stopped volumes: