How to create an email form that can send email using html


I know that are a lot of examples using the mailto: post action to send emails using just html form.

But using that will actually, popup the send email dialog box e.g. outlook dialog box and it is actually using our own smtp server to send the email.

Is there anyway to create html form that will simply send email upon submission?

E.g. if using other javascript api can achieve the effect? say for e.g. node.js?

Can anyone provide some code samples?

11/23/2011 9:56:30 AM

you can use Simple Contact Form in HTML with PHP mailer. It's easy to implement in you website. You can try the demo from following link: Simple Contact/Feedback Form in HTML-PHP mailer

Otherwise you can watch the demo video in following link: Youtube: Simple Contact/Feedback Form in HTML-PHP mailer

When you are running in localhost, you may get following error:

Warning: mail(): Failed to connect to mailserver at "" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in S:\wamp\www\sample\mailTo.php on line 10

You can check in this link for more detailed information: Simple Contact/Feedback Form in HTML with php (HTML-PHP mailer) And this is the screenshot of HTML form: Simple Form

And this is the main PHP coding:

if($_POST["submit"]) {
    $recipient="[email protected]"; //Enter your mail address
    $subject="Contact from Website"; //Subject 
    $mailBody="Name: $sender\nEmail Address: $senderEmail\n\nMessage: $message";
    mail($recipient, $subject, $mailBody);
    header("Location:"); // Set here redirect page or destination page

You can't, the only things you can do with html is open your default email application. You must use a server code to send an email, php, asp .net....


You can't send email using javascript or html. You need server side scripts in php or other technologies to send email.


Html by itself will not send email. You will need something that connects to a SMTP server to send an email. Hence Outlook pops up with mailto: else your form goes to the server which has a script that sends email.


Short answer, you can't.

HTML is used for the page's structure and can't send e-mails, you will need a server side language (such as PHP) to send e-mails, you can also use a third party service and let them handle the e-mail sending for you.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]