Urgent.News

What's breaking now, across thousands of outlets.

Tech

How to send HTML form data to an email address

You have a static page with a contact form. You want what people write in it to arrive in your inbox. You search, and half the answers say mailto: , the other half say "use a backend", and nobody tells you which details will bite you at 2am when a customer says they wrote and you never got it. Here is the whole picture: why HTML alone can't do this, the three options that actually work, and the…

HTML forms cannot send emails directly. The `<form>` element sends data via HTTP request but has no knowledge of email protocols like SMTP, which require authentication. A server sits between the form submission and the mail server, and that server is the critical component.

Options for handling form submissions include:

1. Hosting your own server endpoint to process the form and send email via API or SMTP. This gives full control but adds complexity and maintenance responsibilities.

2. Using a third-party form backend service that stores submissions and forwards them to your email address. This is serverless and hassle-free but means your data lives on a third-party server.

3. Leveraging hosted form builders like Google Forms or Typeform. This is the most convenient for simple contact forms but sacrifices design control and ownership of the form data.

Regardless of the approach, crucial considerations are: never include the visitor's email address in the "From:" field, as this triggers spam filters; instead use your own domain in the "From:" header and set "Reply-To" to the visitor's address. Additionally, handle newlines in form fields properly to avoid header injection vulnerabilities.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Any Nix package, live in your browser

Any Nix package, live in your browser Farid Zakaria calls this his " magnum opus of Nix work", and I can see why. trynix.dev provides a qemu-wasm powered x86_64 Linux virtual machine running entirely…

  • Farid Zakaria created trynix.dev to run Nix packages in a web browser.
  • Uses qemu-wasm to create an x8664 Linux virtual machine within the browser.
  • Enables URL access to virtual machines for interactive shells and pull request previews.

More from Thursday 10 September →