HTML Form That Sends Email Without Server (2026)
To send email from an HTML form without a server, point the form's action at a form backend, add your API key in a hidden apiKey field, and publish the page. The backend receives the POST and emails you each submission, so there is no PHP or Node.js code to write or host.
This guide uses Static Forms. The first form below works as plain HTML with no JavaScript. Later steps add styling, an on-page success message, spam protection and, on the Starter plan, file uploads. The free plan currently includes 250 submissions every 30 days and needs no credit card.
Whether you're building your first website, creating a portfolio, or adding a contact form to a landing page, this guide will walk you through everything step by step. If you teach HTML, see Static Forms for classrooms for a lesson plan built on the same form.
Prefer a working project? The complete HTML example is on GitHub and deploys to Vercel in one click. It's one of 13 framework examples covering Next.js, Nuxt, SvelteKit, Astro, Angular and more.
Why Traditional Methods Are Complicated
Before we dive into the simple solution, let's understand why this used to be difficult:
The Old Way: PHP Mail Scripts
// This requires a PHP-enabled server
<?php
mail($_POST['email'], 'Subject', $_POST['message']);
?>Problems: Requires PHP hosting, vulnerable to spam, often blocked by servers, needs SMTP configuration.
The Old Way: Node.js Backend
// This requires running a Node.js server
const nodemailer = require('nodemailer');
// ...dozens of lines of configurationProblems: Requires server hosting, complex setup, ongoing maintenance, security concerns.
The Simple Modern Way
<!-- Just point your form to a form backend service -->
<form action="https://api.staticforms.dev/submit" method="POST">
<!-- Your form fields -->
</form>Benefits: ✅ No server required, ✅ No coding knowledge needed, ✅ Works immediately, ✅ Built-in spam protection.
What You'll Need
Before we start, make sure you have:
- A text editor (VS Code, Sublime Text, or even Notepad)
- A Static Forms account - sign up free here
- Your API key from the dashboard
- A web browser for testing
That's it! No server, no hosting requirements, no complex installations.
Step 1: Create Your Basic HTML Form
Let's start with the simplest possible contact form. Create a new file called contact.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form</title>
</head>
<body>
<h1>Contact Us</h1>
<form action="https://api.staticforms.dev/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<br><br>
<label for="message">Message:</label>
<textarea id="message" name="message" required></textarea>
<br><br>
<!-- Replace YOUR_API_KEY_HERE with your actual API key -->
<input type="hidden" name="apiKey" value="YOUR_API_KEY_HERE">
<!-- Optional: to send the visitor to your own thank-you page, uncomment this and
change the URL to your page (a full https:// URL) -->
<!-- <input type="hidden" name="redirectTo" value="https://yourwebsite.com/thank-you.html"> -->
<!-- Honeypot: hidden from people, filled in by bots -->
<input type="text" name="honeypot" style="display:none" tabindex="-1" autocomplete="off">
<button type="submit">Send Email</button>
</form>
</body>
</html>That's it! Replace the key (and uncomment the redirectTo line with your URL, if you want a thank-you page), open the file in your browser and send a test message. It arrives in your inbox, and it is also listed in the Inbox in the Static Forms app. Without the redirectTo field, the visitor sees a plain "Form submitted successfully" page, so most sites add their own thank-you page.
How It Works
- The
actionattribute points to Static Forms' API endpoint - The
method="POST"sends the data securely - The hidden
apiKeyfield tells Static Forms where to send the email - Your form fields (
name,email,message) are included in the email, and the visitor'semailbecomes the reply-to address, so you can answer by replying
Step 2: Style Your Form
Let's make it look professional with some CSS:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form - Send Email</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
max-width: 500px;
width: 100%;
}
h1 {
color: #333;
margin-bottom: 10px;
font-size: 28px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
font-size: 14px;
}
input[type="text"],
input[type="email"],
textarea {
width: 100%;
padding: 12px 15px;
border: 2px solid #e0e0e0;
border-radius: 5px;
font-size: 14px;
font-family: inherit;
transition: border-color 0.3s;
}
input:focus,
textarea:focus {
outline: none;
border-color: #667eea;
}
textarea {
resize: vertical;
min-height: 120px;
}
button {
width: 100%;
padding: 14px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
button:active {
transform: translateY(0);
}
.required {
color: #e74c3c;
}
</style>
</head>
<body>
<div class="container">
<h1>Get in Touch</h1>
<p class="subtitle">Fill out the form below and we'll get back to you shortly.</p>
<form action="https://api.staticforms.dev/submit" method="POST">
<div class="form-group">
<label for="name">Your Name <span class="required">*</span></label>
<input type="text" id="name" name="name" placeholder="John Doe" required>
</div>
<div class="form-group">
<label for="email">Your Email <span class="required">*</span></label>
<input type="email" id="email" name="email" placeholder="john@example.com" required>
</div>
<div class="form-group">
<label for="message">Your Message <span class="required">*</span></label>
<textarea id="message" name="message" placeholder="Tell us what's on your mind..." required></textarea>
</div>
<!-- Configuration -->
<input type="hidden" name="apiKey" value="YOUR_API_KEY_HERE">
<input type="text" name="honeypot" style="display:none" tabindex="-1" autocomplete="off">
<button type="submit">Send Email</button>
</form>
</div>
</body>
</html>Now your form looks professional and modern! 🎨
Step 3: Add User Feedback with JavaScript
Let's enhance the user experience by showing a success message without leaving the page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form - Send Email</title>
<style>
/* Include all the CSS from Step 2 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
max-width: 500px;
width: 100%;
}
h1 {
color: #333;
margin-bottom: 10px;
font-size: 28px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
font-size: 14px;
}
input[type="text"],
input[type="email"],
textarea {
width: 100%;
padding: 12px 15px;
border: 2px solid #e0e0e0;
border-radius: 5px;
font-size: 14px;
font-family: inherit;
transition: border-color 0.3s;
}
input:focus,
textarea:focus {
outline: none;
border-color: #667eea;
}
textarea {
resize: vertical;
min-height: 120px;
}
button {
width: 100%;
padding: 14px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
button:active {
transform: translateY(0);
}
button:disabled {
background: #ccc;
cursor: not-allowed;
transform: none;
}
.required {
color: #e74c3c;
}
/* Alert styles */
.alert {
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
display: none;
animation: slideIn 0.3s ease;
}
.alert.show {
display: block;
}
.alert-success {
background-color: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.alert-error {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="container">
<h1>Get in Touch</h1>
<p class="subtitle">Fill out the form below and we'll get back to you shortly.</p>
<!-- Alert message -->
<div id="alertMessage" class="alert"></div>
<form id="contactForm">
<div class="form-group">
<label for="name">Your Name <span class="required">*</span></label>
<input type="text" id="name" name="name" placeholder="John Doe" required>
</div>
<div class="form-group">
<label for="email">Your Email <span class="required">*</span></label>
<input type="email" id="email" name="email" placeholder="john@example.com" required>
</div>
<div class="form-group">
<label for="message">Your Message <span class="required">*</span></label>
<textarea id="message" name="message" placeholder="Tell us what's on your mind..." required></textarea>
</div>
<!-- Configuration (these won't be visible to users) -->
<input type="hidden" name="apiKey" value="YOUR_API_KEY_HERE">
<input type="text" name="honeypot" style="display:none" tabindex="-1" autocomplete="off">
<button type="submit" id="submitButton">Send Email</button>
</form>
</div>
<script>
const form = document.getElementById('contactForm');
const submitButton = document.getElementById('submitButton');
const alertMessage = document.getElementById('alertMessage');
form.addEventListener('submit', async function(e) {
e.preventDefault();
// Show loading state
submitButton.disabled = true;
submitButton.textContent = 'Sending...';
// Hide previous alerts
alertMessage.classList.remove('show', 'alert-success', 'alert-error');
// Get form data
const formData = new FormData(form);
const data = Object.fromEntries(formData);
try {
// Send to Static Forms
const response = await fetch('https://api.staticforms.dev/submit', {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
});
const result = await response.json();
if (result.success) {
// Show success message
alertMessage.textContent = '✅ Success! Your message has been sent. We\'ll get back to you soon!';
alertMessage.classList.add('alert-success', 'show');
// Reset the form
form.reset();
} else {
throw new Error(result.error || 'Failed to send message');
}
} catch (error) {
// Show error message
alertMessage.textContent = '❌ Oops! Something went wrong. Please try again.';
alertMessage.classList.add('alert-error', 'show');
console.error('Form submission error:', error);
} finally {
// Reset button
submitButton.disabled = false;
submitButton.textContent = 'Send Email';
}
});
</script>
</body>
</html>Perfect! Now your form provides instant feedback when emails are sent. ✅
Step 4: Add Spam Protection
Protect your form from spam with these built-in features:
Honeypot Field (Already Included in the Forms Above)
<input type="text" name="honeypot" style="display:none" tabindex="-1" autocomplete="off">This invisible field catches bots. Human users won't see it, but bots will fill it out, identifying themselves.
Add reCAPTCHA for Extra Protection
Include Google reCAPTCHA for stronger spam protection:
Get your reCAPTCHA keys from Google reCAPTCHA Admin
Add the script to your
<head>:
<script src="https://www.google.com/recaptcha/api.js" async defer></script>- Add the widget to your form:
<div class="form-group">
<div class="g-recaptcha" data-sitekey="YOUR_RECAPTCHA_SITE_KEY"></div>
</div>- Configure the secret key in your Static Forms settings
For a complete reCAPTCHA guide, see our understanding reCAPTCHA tutorial.
Advanced Features
Custom Email Subject Line
Set a custom subject for better email organization:
<input type="hidden" name="subject" value="New Contact from Website">Or let users set their own subject:
<div class="form-group">
<label for="subject">Subject</label>
<input type="text" id="subject" name="subject" placeholder="What's this about?">
</div>Reply-To Configuration
If your form has an email field, Static Forms uses it as the reply-to address, so replying to the notification answers the visitor. To send replies somewhere else, add a replyTo field with a valid address. It takes precedence over email:
<input type="hidden" name="replyTo" value="support@yourcompany.com">Redirect After Submission
Send users to a thank-you page instead of the default success page. The value must be a full http:// or https:// URL; a relative path is ignored. Don't use it with the fetch version in Step 3, because a redirect would send fetch to the thank-you page instead of returning the JSON result:
<input type="hidden" name="redirectTo" value="https://yourwebsite.com/thank-you.html">Replace the example URL with your own page.
File Attachments
Allow users to upload files (available from the Starter plan up). Add enctype="multipart/form-data" to the form and a file input:
<form action="https://api.staticforms.dev/submit" method="POST" enctype="multipart/form-data">
<input type="hidden" name="apiKey" value="YOUR_API_KEY_HERE">
<label for="attachment">Attach File (Optional)</label>
<input type="file" id="attachment" name="attachment" accept=".pdf,.doc,.docx,.jpg,.png">
<button type="submit">Send</button>
</form>Files are attached to the notification email when one is sent and stored with the submission. On the Free plan, a submission that includes a file is rejected with a 400. To send files with fetch, pass the FormData object as the body instead of JSON.stringify, because JSON can't carry files. See File Uploads for size limits.
Common Questions
Do I need to install anything on my server?
No! Static Forms handles everything. You just need to add HTML to your website.
Will this work on any hosting provider?
Yes! It works on:
- ✅ GitHub Pages
- ✅ Netlify
- ✅ Vercel
- ✅ Traditional hosting (cPanel, etc.)
- ✅ Any hosting that serves HTML files
Is it really free?
Yes. The free plan currently includes 250 submissions every 30 days, the built-in spam filter, the honeypot field and reCAPTCHA v2, with no credit card. Paid plans add higher limits and more features.
How do I prevent spam?
Use the built-in honeypot field (included in our examples) and optionally add reCAPTCHA for extra protection.
Can I customize the email content?
The email will include all form fields. You can customize which fields appear by adding or removing form inputs.
What if I need more advanced features?
Paid Static Forms plans start at $6/month (or $4/month billed annually) on Starter, which adds:
- Webhook integrations (send data to other services)
- 3,000 submissions a month
- File upload support
- Altcha CAPTCHA (privacy-focused alternative to reCAPTCHA)
- AI Reply and auto-responder emails
- Priority email support
Pro adds Google Sheets, Notion, Airtable and Mailchimp sync, conditional form rules, a custom sending domain, and 25,000 submissions a month.
Troubleshooting
Emails not arriving?
- ✅ Check your spam/junk folder
- ✅ Verify your API key is correct
- ✅ Confirm your account email is verified. Submissions from an unverified account are refused and not stored
- ✅ Open the Inbox in the Static Forms app: if the submission is listed, the form works and the problem is delivery
- ✅ Check the browser console for errors
Form not submitting?
- ✅ Make sure you replaced
YOUR_API_KEY_HEREwith your actual API key - ✅ Check that the form action URL is correct:
https://api.staticforms.dev/submit - ✅ Verify required fields are filled out
- ✅ Look for JavaScript errors in the browser console
Getting a CORS error or a 403?
- ✅ The API accepts cross-origin requests from any domain, so a CORS error usually hides another failure. Open the Network tab and read the response
- ✅ Send either JSON with a
Content-Type: application/jsonheader or aFormDatabody (Step 3 shows JSON; theFormDataversion is in the File Attachments section) - ✅ A
403can mean a CAPTCHA is on for the form but the request had no valid token, domain restriction is on and the request came from a page that isn't allowed, your account email isn't verified, or the form is paused - ✅ A
429can mean too many submissions in a short time, or that the monthly submission limit for your plan is used up
Complete Copy-Paste Solution
Here's the complete, production-ready code you can copy and paste:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form</title>
<style>
body{font-family:Arial,sans-serif;background:#f4f4f4;padding:20px}
.container{max-width:500px;margin:0 auto;background:white;padding:30px;border-radius:8px;box-shadow:0 2px 10px rgba(0,0,0,0.1)}
h1{color:#333;margin-bottom:20px}
.form-group{margin-bottom:15px}
label{display:block;margin-bottom:5px;color:#333;font-weight:600}
input,textarea{width:100%;padding:10px;border:1px solid #ddd;border-radius:4px;font-size:14px}
textarea{min-height:100px;resize:vertical}
button{width:100%;padding:12px;background:#4A90E2;color:white;border:none;border-radius:4px;font-size:16px;cursor:pointer}
button:hover{background:#357ABD}
button:disabled{background:#ccc;cursor:not-allowed}
.alert{padding:10px;border-radius:4px;margin-bottom:15px;display:none}
.alert.show{display:block}
.alert-success{background:#d4edda;color:#155724}
.alert-error{background:#f8d7da;color:#721c24}
</style>
</head>
<body>
<div class="container">
<h1>Contact Us</h1>
<div id="alert" class="alert"></div>
<form id="form">
<div class="form-group">
<label>Name *</label>
<input type="text" name="name" required>
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" name="email" required>
</div>
<div class="form-group">
<label>Message *</label>
<textarea name="message" required></textarea>
</div>
<input type="hidden" name="apiKey" value="YOUR_API_KEY_HERE">
<input type="text" name="honeypot" style="display:none">
<button type="submit" id="btn">Send Email</button>
</form>
</div>
<script>
const f=document.getElementById('form'),b=document.getElementById('btn'),a=document.getElementById('alert');
f.addEventListener('submit',async e=>{
e.preventDefault();
b.disabled=true;
b.textContent='Sending...';
a.className='alert';
try{
const r=await fetch('https://api.staticforms.dev/submit',{
method:'POST',
body:JSON.stringify(Object.fromEntries(new FormData(f))),
headers:{'Content-Type':'application/json'}
});
const j=await r.json();
if(j.success){
a.textContent='✅ Message sent successfully!';
a.className='alert alert-success show';
f.reset();
}else throw new Error();
}catch(e){
a.textContent='❌ Error sending message. Please try again.';
a.className='alert alert-error show';
}finally{
b.disabled=false;
b.textContent='Send Email';
}
});
</script>
</body>
</html>Just replace YOUR_API_KEY_HERE and you're done!
Conclusion
Creating an HTML form that sends emails without a server is now incredibly simple. With Static Forms, you can:
- ✅ Set up a working contact form in under 5 minutes
- ✅ Receive emails directly in your inbox
- ✅ No PHP, Node.js, or server configuration needed
- ✅ Built-in spam protection
- ✅ Works on any hosting platform
- ✅ Start on the free plan, which currently includes 250 submissions every 30 days
Whether you're a beginner building your first website or an experienced developer looking for a simple solution, Static Forms eliminates the complexity of form handling.
Ready to add email functionality to your HTML forms? Sign up for Static Forms and start receiving submissions in minutes!
For more tutorials, check out our guides on GitHub Pages integration, Next.js forms, and Gatsby forms.
Related Articles
Add Email to a Replit Website Contact Form
Connect a Replit website contact form to email with plain HTML and React examples, safe key handling, publishing checks, spam controls, and fixes.
Make a Claude-Generated Website Contact Form Send Email
Fix a Claude-generated website contact form that fakes success. Trace the handler, patch HTML or React, protect secrets, and test the published Artifact.
Make a Lovable Contact Form Send Real Email
Connect a Lovable contact form to real email with a copy-paste React example, safe key handling, spam controls, deployment tests, and troubleshooting.









