All articles
Developer field noteDevelopment5 min read

Why does retrying a contact form send two emails?

Run a local failure lab to separate a repeated request from a new inquiry. Test the gap between saving the inquiry and confirming its notification.

A lost response does not tell you whether the email was sent. The sender might accept the notification before the form receives its confirmation. Retrying the whole operation can then create another email.

Disabling the submit button helps with repeated clicks while the page is waiting. It cannot settle what happened on the server.

This field note gives you a small local experiment for that gap. If you are checking a missing message rather than maintaining the form code, start with our website email delivery guide.

Reproduce the uncertain result

Download the contact-form retry lab, inspect the file, then run it:

node contact-form-retry-lab.mjs

The file needs no packages or credentials. It starts a temporary HTTP server on your computer's loopback address and closes it afterward. We ran it with Node.js v24.13.1 on December 1, 2026.

The requests are real local HTTP requests. The inquiry records and notification sender are in-memory teaching models. No real email is sent, and no outside service is contacted. This is a failure experiment, not a production form handler.

For each of the first three cases, the lab creates an inquiry and lets the simulated sender accept a notification. It then drops the connection before saving the completed form receipt. The client observes a connection reset and retries the same request.

Observed totals after that retry, using synthetic inquiries and simulated notifications.
Lab protectionAfter retry
No retry guards2 inquiries; 2 notifications
One inquiry record per key1 inquiry; 2 notifications
Inquiry record and sender operation key1 inquiry; 1 notification

The middle row is the useful failure. The form recognizes the inquiry but repeats the notification step. A unique inquiry record alone has not protected the second operation.

Give a retry the same identity

Use one submission reference for one intended request. Keep that reference when retrying after an uncertain response. A deliberate new inquiry gets a new reference, even when every field is identical.

A workflow builder asked about this exact distinction: matching an email address or all the form fields can also block legitimate repeat requests.

An idempotency key makes that intent explicit. It tells the receiving system which operation is being repeated. Amazon's guide to safe retries explains why matching parameters alone can confuse two intended operations.

Keep the original input associated with the reference. If that reference arrives with changed details, report the conflict instead of silently returning a receipt for something else. The lab exercises that case separately.

Refreshing the page is an important boundary. If your interface generates a new reference on every page load, a refreshed submission will look new. Decide how an unresolved request retains its reference, and give customers an explicit way to start another inquiry.

Check the notification step separately

The lab uses a second key for the notification operation. When the form lacks its completed receipt, retrying that sender operation returns the earlier simulated message reference.

A real provider has its own contract. Resend currently keeps idempotency keys for 24 hours and supports them on its send-email endpoints. Reusing a key with different input produces a conflict; a request still in progress has a separate conflict response. Read Resend's key and response rules.

That is provider behavior documented by Resend, not behavior this lab tested. The model has no expiry clock and is not a Resend emulator.

Keep the key stable for that notification. Generating a fresh key inside every retry discards the protection you meant to add. Give a customer acknowledgment and an internal staff alert separate operation identities.

If your sender offers no equivalent mechanism, an uncertain result needs investigation or reconciliation. A local “sent” flag does not make the network exchange atomic. Marking it before sending risks skipping a message; marking it afterward leaves a gap if the process stops between those steps.

Read all eight checks

The downloadable file includes assertions, so an unexpected result exits with an error. Add --json to get the same results as structured output.

Besides the three comparisons above, it checks:

  • Failure before the sender: retrying finishes with one inquiry and one simulated notification.
  • Replay after completion: the same request returns the same inquiry and notification references.
  • A new request with identical fields: a new key produces a second inquiry and notification.
  • Changed input under an existing key: the lab rejects it without creating another notification.
  • Overlapping requests: the lab reports one as in progress; retrying after completion returns the original receipt.

Those checks passed in the local run. They do not establish inbox placement, provider behavior, or how a deployed service survives a restart.

Carry the failure case into your application

Use the experiment to choose the checks for your actual stack. In an authorized staging environment, inspect the saved inquiry, the sender's acceptance record and the response separately.

A production implementation needs shared, durable state and an atomic way to claim work across workers. It also needs a recovery policy when a worker stops. The lab's maps and single-process claim do not provide those guarantees.

Scope references to the correct form, account and action. Validate input and access before returning an existing receipt. A submission key is not proof that a caller may read another person's inquiry.

Test a process restart, two workers handling the same key, and a retry beyond your sender's retention window. Reconcile an old unresolved operation before treating it as new. Record which cases your implementation actually passes.

Finally, check the customer message. If you saved the inquiry but cannot confirm its notification, the interface should describe that state accurately. “Nothing was sent” would claim more than you know.

Run the lab, then write down the exact boundary your own form still needs to handle. Our lead follow-up guide covers ownership after the inquiry exists. If you need help testing the route, tell us what happens when your form retries.

JUNCIE STUDIOS

Your website could be
working harder for you.

Tell me what’s getting in the way. I’ll help you figure out the next step for your business.

Talk to me about your website
Brandon Mitchell
Brandon MitchellDesigner, developer & your point of contact.Based in Arizona. Built around your business.