How to build Serverless HTML Forms (3 simple steps with examples)
With MailSlurp you can receive form submissions directly to your email address — no server or Javascript required. Plus it’s free :)
Why? (it’s simple and free)
These days HTML and the Jamstack can achieve a lot. But how do you process form submissions without a server? Well with MailSlurp you can get form submissions sent directly to your email address — file attachments included!
1. Create an HTML form
Simply create an HTML form with method="post"
and action"=https://api.mailslurp.com/forms?_to=YOUR_EMAIL_ADDRESS"
. When the form is submitted all the named inputs will be collected by MailSlurp and sent to the email address provided.
<form
action="https://api.mailslurp.com/forms?_to=YOUR_EMAIL_ADDRESS"
method="post">
<!-- inputs will go here -->
</form>
2. Add inputs you wish to receive
<form
action="https://api.mailslurp.com/forms?_to=YOUR_EMAIL_ADDRESS"
method="post">
<!-- add any input field -->
<input name="birthday" placeholder="Please enter your birthday">
<button type="submit">Submit</button>
</form>
3. Receive submissions to your email address
That’s it! Now try submitting the form. MailSlurp will read the form values and send them to the email address specified.
// example email contents
Subject: New form submission
Body:
- Birthday: 21/05/90
Additionally, you can control form redirection using a hidden _redirectTo
field. Or provide _successMessage
and it will be displays by MailSlurp once the form has been submitted.
To include file attachments use <input type="file" name="file">
and set the form attribute enctype="multipart/form-data"
. For more configuration options see the Forms Documenation.
—
MailSlurp is a free email API service that let’s developers send and receive emails from code and tests. Check it out!