Can JavaScript email a form?

NO! JavaScript can't email a form! but, there are alternatives to send the form data to an email address.

There is no direct method provided by JavaScript to send the data submitted in the form to an email address.

The main concern for not providing a 'JavaScript email form' feature is security.
Suppose there is a feature in JavaScript to send email. Some malicious coder can write a script to send email to some address immediately when you visit their page. This will reveal your email address to some third party without your knowledge. They will start filling your mail box with lots of spam messages!

However, there are alternatives as explained below.


Build Web Forms Faaaast!!

Using Simfatic Forms it is very easy to design, create, install and maintain web forms; no coding required!

Simfatic Forms

Quickly create your form, install it and receive form submissions by email.
Click here for more info


Using 'mailto:'

You can use 'mailto:me@mydomain.com' in the action field of the form. When the user presses the submit button of the form, the browser will first show a warning box that the user's email address will be revealed to the recipient.

email form warning

If the user decides to proceed, the form data will be sent to the address mentioned in the mailto: tag. The browser will open the default mail client to send the data by email.

Sample Code

<form action="mailto:you@yourdmainhere.com" method="post" enctype="text/plain" >
FirstName:<input type="text" name="FirstName">
Email:<input type="text" name="Email">
<input type="submit" name="submit" value="Submit">
</form> 

See the sample code above at work:
JavaScript mail Form Example 1

Notice that this method does not require JavaScript at all.

Disadvantages of 'mailto:' method

It is not possible to control the formatting of the form data. The data submitted in the form is sent by the browser. You can't control the layout of the data.

Browser shows the warning window before sending the data. It may prevent the visitor from submitting the form

Using FormMail

Formmail is run in the server side. A formmail script collects the data submitted in the form and then emails it to a given address. See more information on Formmail here:
Sending HTML form data to an email address

  • Digg
  • del.icio.us
  • Netscape
  • Reddit
  • StumbleUpon
  • Technorati
  • YahooMyWeb

How to make a form without coding? Click here for a demo.

Follow me on twitter

HTML Forms
HTML Form Tutorial
The Form Tag
The Form Submit Button
Form design software
How to make a web form
Make web forms quickly, without coding

Javascript Form Handling
  Basics
Using getElementById to get the elements in a form
Set value of form element using JavaScript
Get value of form element using JavaScript
Handling multiple forms using JavaScript
JavaScript reset/clear a form
  Advanced
JavaScript Form Validation
Submitting a form using JavaScript
Can JavaScript Email a Form?
Switching the form action field dynamically
JavaScript Button

JavaScript Popup Windows
The window.open method
The window.close method
More ...

 
.   Copyright © 2003-2009 JavaScript-coder.com. All rights reserved.