How to build Serverless HTML Forms (3 simple steps with examples)
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
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.
<!-- inputs will go here -->
2. Add inputs you wish to receive
<!-- add any input field -->
<input name="birthday" placeholder="Please enter your birthday">
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
- 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!