From a259c92cb050b040c5f7c0809dc49202c27e957b Mon Sep 17 00:00:00 2001 From: Alejandro Veras Date: Tue, 13 Oct 2026 09:46:20 -0400 Subject: [PATCH] Let the contact form deliver to several inboxes Co-Authored-By: Claude Opus 5.5 --- .env.example | 2 +- README.md | 2 +- src/app/contact/actions.ts | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 6933ea4..0d726a4 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ # Resend — sends contact form submissions by email RESEND_API_KEY= CONTACT_FROM="AI Growth Website " -# Optional: inbox for enquiries (defaults to rey@aigrowth360.io) +# Optional: inbox(es) for enquiries, comma-separated (defaults to rey@aigrowth360.io) # CONTACT_TO= # Optional: Cloudflare Turnstile bot check diff --git a/README.md b/README.md index 780cf1f..1674655 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Copy `.env.example` to `.env.production` (or `.env.local` for development) and f |---|---|---| | `RESEND_API_KEY` | yes | Resend key with sending access to `aigrowthtechnologies.com`. Without it the contact form shows an error. | | `CONTACT_FROM` | yes | Sender, on the domain verified in Resend: `AI Growth Website ` | -| `CONTACT_TO` | no | Inbox that receives enquiries. Defaults to `rey@aigrowth360.io`. | +| `CONTACT_TO` | no | Inbox that receives enquiries; separate several with commas. Defaults to `rey@aigrowth360.io`. | | `TURNSTILE_SECRET_KEY` / `NEXT_PUBLIC_TURNSTILE_SITE_KEY` | no | Cloudflare Turnstile. When both are set, the form shows the challenge. `NEXT_PUBLIC_*` values are baked in at build time, so rebuild after changing it. | ## Deploying to a VPS diff --git a/src/app/contact/actions.ts b/src/app/contact/actions.ts index 84e8f43..51ce587 100644 --- a/src/app/contact/actions.ts +++ b/src/app/contact/actions.ts @@ -4,8 +4,11 @@ import { headers } from "next/headers"; export type ContactState = { status: "idle" | "sent" | "error"; message?: string }; -// Where enquiries land. Override with CONTACT_TO in the environment if it ever changes. -const TO = process.env.CONTACT_TO || "rey@aigrowth360.io"; +// Where enquiries land. Override with CONTACT_TO (comma-separated for several inboxes) if it ever changes. +const TO = (process.env.CONTACT_TO || "rey@aigrowth360.io") + .split(",") + .map((a) => a.trim()) + .filter(Boolean); // Resend's shared sender only delivers to the address that owns the Resend account. To send to TO // from any other account, set CONTACT_FROM to an address on a domain verified in Resend // (e.g. "AI Growth Website "). @@ -97,7 +100,7 @@ export async function sendContact(_prev: ContactState, formData: FormData): Prom try { await sendEmail(apiKey, { - to: [TO], + to: TO, reply_to: email, subject: `New enquiry — ${company || name}`, text: `${rows.map(([k, v]) => `${k}: ${v}`).join("\n")}\n\n${message}`,