πŸ“– Complete Guide

How to Send a Form to Email
(No Backend Required)

The definitive guide with copy-paste code. Works on any static site β€” GitHub Pages, Netlify, Vercel, plain HTML. No PHP, Node, or server needed.

πŸ“– 8 min readπŸ”§ 4 working examples⚑ Works today

Why you can't just email form data with plain HTML

HTML forms are designed to send data somewhere β€” but that "somewhere" needs a server-side script (PHP, Node.js, Python…) to receive the POST request and forward it to your email. If you're building a static site, you don't have that luxury.

⚠️
The myth: action="mailto:" Setting the form action to a mailto link is not reliable. It depends on the visitor having a desktop mail client configured. Broken on most mobile devices. Produces raw URL-encoded garbage. Don't use it in production.

So what's the right way? You have three real options, and we'll walk through all of them.

3 approaches compared

ApproachSetup timeReliabilityBest for
mailto: link⚑ Zero❌ Very poorQuick prototypes only
Form backend service⚑ ~5 minβœ… ExcellentMost static sites
Self-hosted scriptπŸ”§ Hours+βœ… Full controlComplex custom needs

Approach 2: Form backend service (recommended)

A form backend service is a hosted endpoint that accepts your form's POST request and delivers the data to your email. You point your HTML at their URL β€” they handle everything else. This is the right answer for nearly every static site.

βœ…
Why this is the correct approach for most developers Zero server code. Your form HTML stays the same. You get well-formatted emails. Takes 5 minutes. Handles spam filtering, storage, and retries for you.

How it works in 3 steps

  1. Create an endpoint

    Sign up for a form backend service and create a new form. You get a unique URL like https://api.submitrax.com/f/abc123.

  2. Point your form's action at that URL

    Change your form's action attribute to the endpoint. Set method="POST". Add your fields with name attributes.

  3. Every submission arrives in your inbox

    The service emails you the form data nicely formatted. You can also view submissions in a dashboard, export to CSV, and more.

Basic working example

HTML
<form
  action="https://api.submitrax.com/f/YOUR_FORM_ID"
  method="POST"
>
  <input type="text"   name="name"    placeholder="Your name"    required>
  <input type="email"  name="email"   placeholder="Your email"   required>
  <textarea             name="message" placeholder="Your message"></textarea>

  <!-- Optional: redirect to a thank-you page after submit -->
  <input type="hidden" name="_redirect"
         value="https://yoursite.com/thanks">

  <button type="submit">Send message</button>
</form>

AJAX version β€” show a success message without a page reload

Want to display "Thanks!" in place without redirecting? Use fetch with Accept: application/json:

HTML + JS
<form id="contact">
  <input name="name"    placeholder="Name"    required>
  <input name="email"   type="email" required>
  <textarea name="message"></textarea>
  <button type="submit">Send</button>
</form>
<p id="thanks" hidden>βœ… Message sent β€” we'll be in touch!</p>

<script>
document.getElementById('contact').addEventListener('submit', async e => {
  e.preventDefault();
  await fetch('https://api.submitrax.com/f/YOUR_FORM_ID', {
    method: 'POST',
    body: new FormData(e.target),
    headers: { Accept: 'application/json' }
  });
  e.target.hidden = true;
  document.getElementById('thanks').hidden = false;
});
</script>

Approach 3: Self-hosted (advanced)

If you already have server hosting and want complete control, you can write a small email handler. Here's the minimal PHP version:

PHP
<?php
// contact.php β€” minimal example. Add CSRF, rate limiting,
// and SMTP (not mail()) before shipping to production.
if ($_SERVER['REQUEST_METHOD'] !== 'POST') exit;

$name    = htmlspecialchars($_POST['name'] ?? '');
$email   = filter_var($_POST['email'] ?? '', FILTER_SANITIZE_EMAIL);
$message = htmlspecialchars($_POST['message'] ?? '');

mail(
  'you@yoursite.com',
  "Contact from {$name}",
  "From: {$name} <{$email}>\n\n{$message}",
  'From: noreply@yoursite.com'
);
header('Location: /thanks.html'); exit;
ℹ️
Production PHP needs more The example above is intentionally minimal. A production mailer needs CSRF protection, rate limiting, proper SMTP via PHPMailer or Symfony Mailer, spam filtering (honeypot or reCAPTCHA), and input validation. That's easily a day of work β€” which is why a form backend is usually the smarter choice.

Full working example

Here's a complete contact form built with SubmitraX. Fill it in β€” it actually works:

βœ‰οΈ Live contact form demo

Demo form powered by SubmitraX. Create yours free.

The complete code behind this form:

HTML
<form action="https://api.submitrax.com/f/YOUR_ID" method="POST">
  <input type="text"  name="name"    required>
  <input type="email" name="email"   required>
  <textarea            name="message"></textarea>
  <button type="submit">Send</button>
</form>
<!-- That's literally it. -->
⚑ Skip the setup

Do this instantly with SubmitraX

Create a form endpoint in 60 seconds. Point your HTML at it. Get submissions straight to your inbox β€” no servers, no code, no infrastructure to manage.

Create your free form β†’
βœ“ Free plan availableβœ“ No credit card requiredβœ“ Works on any static site