<form action="mailer.php" method="post" novalidate>
<input value="Your Name" name="NAME" class="autoclear name-newsletter" >
<input value="Your Email" name="EMAIL" class="email-newsletter" >
<input value="Your Phone" name="PHONE" class="phone-newsletter" >
<input type="submit" value="submit" name="subscribe" class="button-newsletter">
<label> * We will not forward your email address to any third party.</label>
</form>
我想设置一个php来发送一封包含上述信息的电子邮件,而不是订阅
答案 0 :(得分:1)
下面的示例将发送电子邮件,但您应该添加验证码,以及可能的其他形式的安全性,以防止表单被垃圾邮件。
取自PHP.net
<?php
$success = '';
$to = 'you@example.com';
$subject = 'Newsletter Subscriber';
$message = 'Name: '.$_POST['NAME']."\r\n".
'Email: '.$_POST['EMAIL']."\r\n".
'Phone: '.$_POST['PHONE'];
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)) {
$success = "Success! Your email has been sent!";
}
?>
答案 1 :(得分:0)
您可以使用php记录的邮件功能:
http://php.net/manual/en/function.mail.php
使用帖子数据在mailer.php上执行mail功能。
修改
此代码应该有效(将其放入邮件程序。
<?php
$message = 'Name: '.$_POST['NAME']."\n".
'Email: '.$_POST['EMAIL']."\n".
'Phone: '.$_POST['PHONE'];
mail($to, $subject, $message)
?>