
There are other scripting languages you can use in the backend programming, like Ruby, Perl, or ASP for Windows. Using this data, the backend script can create a database of form submissions, direct the user to another page (e.g. The server then passes the data to the script specified in the action URL - myform-processor.php in this case. When the form is submitted, the browser sends the information to the backend using the link mentioned in the "action" attribute of the form tag, sending the form data to that URL.

The visitor's web browser uses HTML code to display the form. This one stands for Hypertext Preprocessor, and this language collaborates with HTML to process the form.īefore jumping into the process, let's break down a few form basics.Ī webform has two sides: The front-end, seen in the browser by visitors, and a backend script running on the server. To create a form subscribers can contact you with, the PHP script is going to be your best friend. Method 2: Create an Email Send Form Using PHP (Advanced) To make the form work with your email server and send it to a mailbox, PHP is the answer - let's explore that option now. So, what HTML code allows you to send form submissions directly to an email address?

This can spook the user out of submitting the form at all. This form doesn't directly send to email addresses, but rather opens an email client or tool window to submit the form. While you can use just basic HTML, this isn't the ideal option. For a more beautiful one, you'll have to add some more lines of code specific to your needs. Note that this code is basic - it won't look super snazzy. This code will create a form that asks for the contact's name, message, and includes a submit button (not visible in CodePen). See the Pen How to Create an HTML Form That Sends You an Email by HubSpot ( on CodePen. Using just HTML? From starting fresh, here is a sample code for use: Method 1: Create an Email Send Form Using HTML (Not Recommended) Below, we go over the different options available. This is to say that things are a little different if the plan is to use a mix of HTML and different scripts. The option you choose depends on how you work and what platform you're using. For example, it isn't 100% compatible with all browsers, it isn't very user-friendly, and it's impossible to control the formatting of the data when the form is sent by the browser.īeyond that, a warning message will pop up when the user goes to submit the form, letting them know that the information they're about to send will not be encrypted for privacy.īelow, we go over a few options for creating an HTML form that emails you when a new entry is submitted. There are a few problems with the mailto: option. The web browser sends a request to the email service provider, not to the specified address.

This option activates the default mail client on the user's computer, prompting them to send the form over email.

However, the reason they don't is that emailing directly from an HTML web form would reveal the visitor's email address, making the user vulnerable to malicious activities, such as phishing.Īdding a mailto: address to the form can be a potential way to circumvent this challenge. Ideally, browsers would allow you to route form submissions directly to an email address. This is a last-ditch option if you can’t create a PHP-based form. However, you can use the form action element to set a mailto: address (in this case, your own), triggering the submitter’s mail client to open. HTML doesn’t offer an option to create a form that sends an email after submission.
