Next.js Contact Form Not Sending Email: A Delivery Debugging Guide

At a glance
Trace the request from browser to endpoint, email provider and recipient inbox. Check both HTTP status and application results before showing success; provider acceptance alone is not proof that a message reached the intended inbox.
A contact form can show a green success message while the business receives nothing. The browser may have ignored an error response, the server may have accepted the request without sending it, or the email service may have rejected the sender.
Diagnose the delivery path in order: browser → your Next.js endpoint → email service → recipient mailbox. Find the first step that lacks evidence before changing another setting. This guide concerns your own contact form; it is not a reason to send repeated test messages to customers.
First, define what “working” means
For a small business, the useful outcome is a valid enquiry reaching the intended recipient with enough information to reply. A button animation, successful build or HTTP 200 alone does not establish that outcome.
Use a clearly labelled test with fictional details and an inbox you control. Write down the test time, public URL and an identifying reference such as CONTACT-DEMO-01. Keep real API keys and customer messages out of screenshots and public bug reports.
1. Did the browser send the expected request?
Open the browser's Network panel before submitting. Locate the contact request and inspect the method, URL, status and response body.
- No request: check client validation, disabled controls and JavaScript errors.
- 404: verify the endpoint path and deployed files.
- 405: check the HTTP method supported by that endpoint.
- 400 or 422: inspect the validation response and submitted field names.
- 500 or another server error: use the request time or reference to find the corresponding server log.
For an App Router endpoint such as app/api/contact/route.ts, the exported method must match the request. The Next.js Route Handler reference explains method exports and reading JSON or FormData. A JSON request and a native form submission do not necessarily produce the same body format.
2. Is the UI reporting success too early?
A common mistake is showing success as soon as await fetch finishes. Fetch can resolve normally for an HTTP error response; check the status as well as the application's result. See MDN's Fetch guidance.
This illustrative helper expects your own endpoint to return accepted: true only after the send request is accepted by the email provider or the work is safely stored for processing:
type Enquiry = {
name: string;
email: string;
message: string;
};
export async function submitEnquiry(payload: Enquiry): Promise<string> {
const response = await fetch('/api/contact', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
const result = await response.json().catch(() => null);
if (!response.ok || result?.accepted !== true) {
throw new Error('Your enquiry could not be submitted. Please try again.');
}
return typeof result.reference === 'string' ? result.reference : '';
}
Handle the rejected promise in the form: keep the user's entered text and display an understandable error. An empty returned reference is still an accepted result under this example contract; it is not evidence that an email arrived.
The endpoint contract matters more than this field name. Do not return accepted: true unconditionally. If the server uses a queue, HTTP 202 indicates accepted processing, not a completed delivery. Match the confirmation text to the event you can support.
3. Check production configuration without printing secrets
When the form works locally, compare the local and deployed variable names and the environments they are configured for. Confirm that the running release has the intended configuration; do not assume editing a dashboard setting changed an existing build.
A useful inventory lists the variable's name, purpose and environment, with a simple present/missing check. Never dump process.env into logs to investigate one missing key.
The email service's secret belongs on the server. Prefixing it with NEXT_PUBLIC_ to make it accessible to browser code exposes it rather than fixing the architecture. The Next.js environment-variable guide explains browser exposure and build-time inlining of public values.
Also check the actual recipient variable. A staging inbox accidentally retained in production can make delivery look broken when messages are simply going somewhere else.
4. Confirm what the email service accepted
Inspect the provider's request log for this test, using its message identifier where available. If no corresponding event exists, investigate the application-to-provider step: missing configuration, an unhandled error, an omitted await or a request that never reached the sending code.
Inspect the SDK's documented result, not just whether it threw an exception. For example, Resend's send-email reference demonstrates a result containing data and error. Code that ignores error can manufacture a successful application response after a failed provider request.
Await the work required for your stated confirmation, or hand it to a suitable durable processing mechanism. Starting a promise and returning immediately gives you no clear evidence that the send finished. If retrying after an ambiguous timeout, use the provider's supported duplicate-prevention mechanism where appropriate; blind retries can send the same enquiry repeatedly.
5. Check the sender and reply address separately
Use a sender allowed by the provider and your domain configuration. A visitor's email address should not automatically become the From address: you do not control or verify their domain. Put a validated visitor address in the supported Reply-To field when that fits your implementation.
As one concrete provider example, Resend requires an owned, verified sending domain; its domain guide explains that setup. Other providers have their own sender requirements, so follow the service you actually use.
Check records against the exact values supplied by the provider, and confirm you are editing the authoritative DNS zone. Do not paste random SPF or DKIM records from a tutorial or delete existing email records just to make a verification badge change.
6. Follow delivery evidence into the mailbox
Provider acceptance and a message identifier are useful checkpoints, but neither proves the recipient saw the message. Inspect the provider's delivery or failure information, then confirm with the destination inbox you control. Check spam folders, mailbox rules, forwarding and quarantine where accessible.
Keep the recipient, sender, reference and time together. Resend's sending overview points to its message dashboard and API logs. Use the equivalent tools for your provider.
If the provider reports a problem, address that specific cause. If the receiving system accepted the message but it is not visible, investigate mailbox handling rather than repeatedly changing your form component.
A worked diagnosis: the bakery receives no enquiries
Consider a fictional bakery whose form always displays “Message sent.” A labelled test produces a 500 response in the browser. The route log shows the provider rejected the sender; the frontend nevertheless displayed success after fetch resolved.
There are two fixes: correct the authorised sender configuration and make the frontend respect the endpoint's failure result. Fixing only the sender leaves the same misleading UI ready to conceal a future outage. Fixing only the UI reports the problem more honestly but does not restore delivery.
After both changes, repeat one test from the deployed domain and confirm it in the intended inbox. Retain a minimal test record without storing the whole message indefinitely.
Test failures as well as the happy path
Before accepting the form as finished, check these scenarios in a controlled environment:
- A valid labelled submission reaches the intended test inbox.
- Missing or malformed fields produce a clear error and no send attempt.
- A simulated provider failure does not produce a success message.
- An unexpected non-JSON response is handled without losing the draft.
- Repeated clicks do not create uncontrolled duplicate requests.
- Mobile and keyboard users can submit and find the result message.
Validate input server-side, bound field lengths and apply suitable abuse controls. Keep recipients under server control so the endpoint cannot be repurposed as an arbitrary email-sending service. Escape visitor content appropriately when building HTML emails.
Download the delivery-check checklist for your own test record. If this is a client project, include the confirmed result in the Next.js website handover checklist. If the endpoint itself is unclear, start with the API and webhook guide.
A useful bug report is a chain of evidence
Record the affected URL, deployed revision, test reference, browser status, corresponding server event, provider result and recipient confirmation. Mark unknown stages as unknown. That short chain is more actionable than “emails do not work,” and it prevents a visual success message from becoming your only definition of a working form.
Try our QR Code Generator
Create clean, scannable QR codes for testing websites, URLs, and client handoffs.

Ukasha Altaf
Software Developer & Digital Tools Creator
Founder of Ukasha Mart. Building free, accessible browser-based utilities and writing in-depth tutorials on modern technology, freelancing, and practical online work.
Explore Further