-2
<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 来发送包含上述信息的电子邮件,而不是订阅

4

2 回答 2

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!";
}

?>
于 2013-01-31T21:01:41.520 回答
0

您可以在此处使用 php 记录的邮件功能:

http://php.net/manual/en/function.mail.php

使用 post 数据在 mailer.php 上执行邮件功能。

编辑

此代码应该可以工作(将其放入 mailer.

<?php
$message = 'Name:  '.$_POST['NAME']."\n".
           'Email: '.$_POST['EMAIL']."\n".
           'Phone: '.$_POST['PHONE'];

mail($to, $subject, $message)
?>
于 2013-01-31T21:00:32.427 回答