You are currently viewing Creating an HTML form that sends email responses to your inbox

Creating an HTML form that sends email responses to your inbox

Reading Time: 5 minutes

Yes, it is true that improving the UX of a website will cost a lot of money. Also, you don’t need to spend a lot of money every time you face a problem with your website. There are simple fixes.

The question is, how can you find out if your target audience is enjoying the website experience? The answer is very simple. All you have to do is have HTML forms on your website.

This is a great way to get customer feedback about their experience. These forms will offer you insights on how to improve the website UX for more conversions in the future.

Did you know that 74% of the marketers make use of the forms to get more leads? Whether you want to convert more visitors to leads, gather information for the sales team, or want to create solid brand awareness, the forms can help you in a lot more ways than you can think of.

Therefore, in this blog today, we are going to help you in creating HTML forms that send email responses. However, it is not that simple. It will depend on how you work and on what platform you are working with.

If you are only working on HTML then it is pretty easy. Here is a sample code:

<form action=”mailto:contact@yourdomain.com”

method=”POST”

enctype=”multipart/form-data”

name=”EmailTestForm”>

Name:<br>

<input type=”text” size=”24″ name=”VisitorName”><br><br>

Message:<br> <textarea name=”VisitorComment” rows=”4″ cols=”20″>

</textarea><br><br> <input type=”submit” value=”Submit”> </form>

This will create a form like this:

basic HTML form
basic HTML form

This is a basic HTML form. However, the problem is, it doesn’t send the feedback directly to an email. Instead, the HTML code opens an email client window to submit the form.

The problems of email forms in HTML

The reason why browsers don’t allow submitting forms directly to an email address is sending emails directly from an HTML web form that will reveal the visitors’ email address. Thus, the visitor will become vulnerable to malicious activities like phishing.

An HTML code activates the default mail client on the user’s computer. The web browser sends a request to the email service provider and not to the specific address.

The HTML code needs a JavaScript to validate the form and PHP coding for communicating with your email server and send the content to a mailbox. The following three sets of code will get your job done.

HTML:

<form method=”post” name=”contact_form” action=”contact-form-handler.php”> Your Name: <input type=”text” name=”name”> Email Address:

<input type=”text” name=”email”> Message:

<textarea name=”message”></textarea>

<input type=”submit” value=”Submit”>

</form>

JavaScript:

<script language=”JavaScript”>

var frmvalidator = new Validator(“contactform”); frmvalidator.addValidation(“name”,”req”,”Please provide your name”); frmvalidator.addValidation(“email”,”req”,”Please provide your email”); frmvalidator.addValidation(“email”,”email”, “Please enter a valid email address”); </script>

PHP:

<?php

$errors = ”;

$myemail = ‘yourname@website.com’;//<—–Put Your email address here. if(empty($_POST[‘name’]) ||

empty($_POST[’email’]) ||

empty($_POST[‘message’]))

{

$errors .= “\n Error: all fields are required”;

}

$name = $_POST[‘name’];

$email_address = $_POST[’email’];

$message = $_POST[‘message’];

if (!preg_match(

“/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i”, $email_address))

{

$errors .= “\n Error: Invalid email address”;

}

if( empty($errors))

{

$to = $myemail;

$email_subject = “Contact form submission: $name”;

$email_body = “You have received a new message. “.

” Here are the details:\n Name: $name \n “.

“Email: $email_address\n Message \n $message”;

$headers = “From: $myemail\n”;

$headers .= “Reply-To: $email_address”;

mail($to,$email_subject,$email_body,$headers);

//redirect to the ‘thank you’ page

header(‘Location: contact-form-thank-you.html’);

}

?>

How to create an HTML form that emails the responses to the mailbox?

Now, the above-mentioned codes are not difficult but it will take a lot of time for you. If you don’t want to use so many codes, then the following options will get the job done.

Form plugins for WordPress

WordPress brings you a lot of paid and free plugins for you to work on. With these plugins, you can create multiple forms that perform correctly.

Ninja Forms: These are perfect for beginners. You can create custom forms, modify each field, and then save them for later. If you need to indicate required fields or custom input masks for international phone numbers, then this one can do it for you. Also, you can even add your own raw HTML to include videos or custom graphics to increase branding. Ninja forms also help you in avoiding spams through Google reCaptcha, honeypot options, and more.

WP Forms: It includes a user-friendly interface along with a drag-and-drop builder for creating beautiful and functional forms. You can use the free Lite version or you can opt for the paid version as well. The conditional smart logic allows you to choose whether or not to display the additional fields depending on the previous answers.

Also, WPForms securely integrates with multiple payment options like Stripe, PayPal, and more. Thus, it is perfectly suitable for e-commerce applications. You can use the WPForms for developing your email list.

Gravity Forms: Gravity Forms help a lot in saving time. The interface is simple, easy to use, and integrates with numerous popular services like Paypal, Slack, Zapier, Campaign Monitor, and Stripe. There are 30 premade customizable templates that will help you get started.

You can use the conditional logic technology for creating dynamic entry fields depending on answers to different questions. Gravity Forms are committed to responsive design. The forms look perfect on every device. Also, Gravity Forms will send a notification with every submission.

Shopify form Apps

Shopify offers its own series of applications that will help in creating a form and send email responses.

Using the Hulk Apps Easy to Advance Form Builder, you can use premade templates or design your own forms for multiple purposes. You can use them for getting leads. collect payments and also manage customers.

You can create HTML forms that email multiple addresses along with notifications. Also, you can design completely responsive forms for free.

Also, you can use the form builder for custom forms using AAAeCommerce Inc. You can use the easy drag-and-drop builder for creating mobile-responsive forms. You get a lot of similar features like the WP plugins integrated with email apps and PayPal. If you want to create an HTML form that will send responses to an email, you can choose multiple recipients with this.

Google Form

With the Google Forms, you will be able to create beautiful surveys for your email marketing campaigns. Since it is through Google, you and your team can easily collaborate.

The best thing about Google Forms is, you can upload logos, graphics and the website builder will choose the right color to match. The forms are mobile responsive. Also, Google will change them into real-time charts and graphs.

In conclusion, it can be said that user feedbacks are very important in web development, designing, and digital marketing. You will find it very hard to create a strictly HTML form that submits to an email. The technology will not communicate with an email server. However, you can use the HTML form that emails responses by using JavaScript and PHP. Also, you can opt for the user-friendly drag-and-drop plugins.