HTML Contact Form: Free Code That Emails You
To add a contact form to an HTML website, paste the form below into your page, point its action at https://api.w3forms.com/submit and add your free access key. Every message is emailed to you and saved in a dashboard, with spam filtered out. No server, PHP or JavaScript needed, and it works on any host.
Last updated November 27, 2026.
- Create a free W3Forms account and a form. Copy the access key shown once.
- Optional: in Form → Settings, list your site under Allowed domains, so posts from other sites are marked as spam. Include the port when testing locally (for example
localhost:5500). - Paste the markup below. Replace
YOUR_ACCESS_KEYwith your key. - Submit a test. Check the dashboard inbox and your notification email.
Works on GitHub Pages, Netlify, Vercel, Cloudflare Pages, S3, or any host that serves static files. To send people to your own thank-you page, set a Success redirect URL (for example /thanks.html) in Form → Settings; without one, the browser shows a short JSON confirmation.
Want an inline success message without leaving the page? Use the HTML + fetch generator.
<form action="https://api.w3forms.com/submit" method="POST">
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
<label for="name">Name</label>
<input type="text" id="name" name="name" required />
<label for="email">Email</label>
<input type="email" id="email" name="email" required />
<label for="message">Message</label>
<textarea id="message" name="message" required></textarea>
<input type="text" name="_gotcha" tabindex="-1" autocomplete="off"
aria-hidden="true" style="position:absolute;left:-9999px" />
<button type="submit">Send</button>
</form>Questions
How do I make an HTML contact form send email?
HTML alone can't send email, so the form has to post to a service that does. Set the form's action to https://api.w3forms.com/submit, add a hidden access_key input, and W3Forms emails each message to you and saves it in your dashboard.
Do I need PHP, a server or JavaScript?
No. The form posts straight to W3Forms, so it works on static hosts like GitHub Pages, Netlify, Vercel and Cloudflare Pages. JavaScript is only needed if you want to show a success message without leaving the page.
How do I show a thank-you page after someone submits?
Set a Success redirect URL in Form → Settings, for example /thanks.html or a full URL on the same site. Without one, the browser shows a short JSON confirmation.
How do I stop contact form spam?
The example includes a hidden honeypot field named _gotcha, which bots fill in and people don't. You can also turn on a captcha, block keywords and disposable email addresses, and list your allowed domains. Spam is stored separately and never emailed.
Is it free?
Yes. The free plan has unlimited forms and unlimited submissions, with no credit card. File uploads work too, up to 10 MB per file, if you add enctype="multipart/form-data" to the form.
Is W3Forms the same as Web3Forms?
No. W3Forms (w3forms.com) is a separate product and isn't affiliated with Web3Forms. Check that your form's action points at api.w3forms.com.
See also
- Contact form template: build one without code
- HTML form generator
- Looking for a Formspree alternative? W3Forms vs Formspree
Next steps
- Generate a correct honeypot
- Validate your form HTML
- Configure redirects and spam settings
- Add a signed webhook
- Compare W3Forms to Formspree & others