Forms, Orders, and Email Automation
Follow one inquiry from checked input to a saved record, handle duplicates, tell the visitor only what you know, and plan for the moment you can't tell whether an email went out.
Content date: October 15, 2026.
Plain English
A form is a process, not just fields and a thank-you message. Decide what "submitted" means: checked, saved, queued, accepted by an email provider, or delivered. What you tell the visitor has to match what your system can actually confirm. Checks in the browser help people fix typos, but the checks that protect you must run on the server, where the data is really processed.
Use this when
Do this when your site starts collecting inquiries, requests, or any action that someone has to receive and handle. Add orders or payments only if your business really works that way.
If you are just starting
Build one inquiry form with only the fields you need, clear labels, length limits, error messages that keep what the person already typed, and an honest confirmation. Start with the no-network simulation to see how duplicates and delivery states behave. Keep the sender and recipient addresses in trusted configuration (see "Email Setup"). Skip the CRM, newsletter signup, and payments unless your product needs them.
When your project grows
Save each inquiry before you try to email anyone, and send through an outbox (a saved to-do list of messages to send) or your provider's own duplicate protection. Decide what a submission key identifies, what happens when the same key arrives with a different message, and what happens when two attempts arrive at once. Run spam and abuse checks before doing costly work, verify that provider events are genuine, and decide how long to keep inquiries, who can read them, and how to reconcile failures. A timeout can leave the outside result unknown. Keep a recoverable record of every inquiry and alert the person responsible, instead of promising delivery or retrying forever.
Worked example
A visitor to a school club sign-up page clicks Submit twice with the same key and message. The server returns the same receipt both times and contacts the email provider once. Reusing the key with a different message returns a conflict. If the first send timed out, the second click shows the same unknown status until someone checks.
Practice
Trace an inquiry through failure states
- Read the delivery workbook and the local inquiry simulation, and predict each state change before you run anything.
- Run the fixture checks for invalid input, repeated and conflicting keys, acceptance, rejection, unknown results, and later events.
- For each result, write the visitor's message and the operator's action, without claiming delivery you can't confirm.
- Explain why an in-memory map and simulated events can't prove saved records or authentic provider events.
- Add to your real project's readiness list: server checks, error recovery, spam protection, storage, event verification, and a test with a designated inbox.
Deliverable: A state diagram, your fixture results, visitor and operator messages for each state, and a separate plan for testing end to end with a real provider.
Common mistakes to watch for
- A form shows "Thanks!" before the inquiry is saved, and a server error silently loses a customer's request.
- A visitor double-clicks Submit and the shop gets two notifications, or two orders.
- A retry reuses an old key for a new message, and the new inquiry is quietly dropped.
- A visitor's text lands in an email header or recipient field, and your form starts sending spam.
Prompting
A weak prompt
Make a contact form that sends an email and always shows Thanks after clicking Submit.
A better prompt
Build a small inquiry form for [my site]. Validate every field on the server with length limits, keep sender and recipient in configuration, and use a submission key so a double click doesn't create two inquiries. Keep what the visitor typed on errors, and confirm only what we know. Test without sending real mail: invalid input, a repeat, the same key with a changed message, provider rejection, a timeout, and a later failure event. List what production still needs: storage, simultaneous requests, spam protection, and event verification.
The visitor and the person handling inquiries both get an honest account of what happened, including when delivery is unknown.
Check before you move on
- Your confirmation says only what the system knows.
- The server checks and caps every field.
- Sender and recipient are set in configuration.
- Repeat and conflicting submissions each have a defined result.
- Unknown outcomes are visible and not silently retried.
- You listed what a production version still needs.
You are done when
- Each practice case has a traceable result, and no unknown outcome triggers a blind resend.
- Your notes separate the local simulation from real saved inquiries and real inbox delivery.
Questions to think about
Your email provider says it accepted a message. What can your confirmation page honestly say?
That your request was received and is being processed. Acceptance doesn't prove the recipient got or read it, so don't say it was delivered.
A second request arrives with the same key but a different message. Why answer with a conflict?
The key identifies the first request. Treating the new text as a repeat would throw it away without telling anyone.
A developer keeps seen submission keys in a variable in server memory. Why isn't that enough in production?
Memory disappears on restart and isn't shared between servers, so duplicates slip through. You need storage that persists and coordinates, and tests that restart and run two copies.