如何创建可以使用html发送电子邮件的电子邮件表单

我知道有很多例子使用mailto:post操作发送电子邮件只使用html形式。

但使用它实际上,弹出发送电子邮件对话框例如。 outlook对话框,它实际上是使用我们自己的smtp服务器发送电子邮件。

有没有反正创建html表单,将只提交发送电子邮件?

例如。如果使用其他javascript api可以实现效果?说例如node.js?

任何人都可以提供一些代码示例?

正如其他人所说,你不能。
你可以在网络上找到HTML-php表单的好例子,这里是一个非常有用的链接,结合HTML与JavaScript的验证和PHP的发送电子邮件。

请检查源代码中的完整文章(包括zip示例):
http://www.html-form-guide.com/contact-form/php-email-contact-form.html

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>

JS:

<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');
}
?>
http://stackoverflow.com/questions/8239782/how-to-create-an-email-form-that-can-send-email-using-html

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:如何创建可以使用html发送电子邮件的电子邮件表单