Let the contact form deliver to several inboxes
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
# Resend — sends contact form submissions by email
|
||||
RESEND_API_KEY=
|
||||
CONTACT_FROM="AI Growth Website <hello@aigrowthtechnologies.com>"
|
||||
# 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
|
||||
|
||||
@@ -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 <hello@aigrowthtechnologies.com>` |
|
||||
| `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
|
||||
|
||||
@@ -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 <hello@aigrowthtechnologies.com>").
|
||||
@@ -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}`,
|
||||
|
||||
Reference in New Issue
Block a user