Advertisement
Advertisement


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


Question

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?

2011/11/23
1
50
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 "smtp.gmail.com" 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:

<?php
if($_POST["submit"]) {
    $recipient="[email protected]"; //Enter your mail address
    $subject="Contact from Website"; //Subject 
    $sender=$_POST["name"];
    $senderEmail=$_POST["email"];
    $message=$_POST["comments"];
    $mailBody="Name: $sender\nEmail Address: $senderEmail\n\nMessage: $message";
    mail($recipient, $subject, $mailBody);
    sleep(1);
    header("Location:http://blog.antonyraphel.in/sample/"); // Set here redirect page or destination page
}
?>
2017/07/27

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....

2011/11/23

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

2011/11/23

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.

2011/11/23

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.

2018/03/31

Source: https://stackoverflow.com/questions/8239782
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]