0

The form and the PHP code are working fine, but the only problem I am having with this is that it will not send an email to me nor to the person signing up. Please if you could look at the codes to see what I am doing wrong.

Thanks in advance.

This the HTML.

<div id="formWrapper">

<form action="formprocess.php" method="post">


  <fieldset class="first">
  <h3>Welcome to the SBOCC Questions & Comments Page.</h3>
  <h4>Please fill out the form below with your question(s) or comment(s)<br> 
  so that you may receive an answer. Shalom (Peace). BLESS THE COMFORTER.
  </h4>
  <label class="labelOne" for="name">Your Name:</label>
  <label class="two" for="optional">(Required)</label>
  <input name="name" />

  <label for="email">Your Email:</label>
  <label class="three" for="required">(Required)</label>
  <input name="email" />

  <label for="questionscomments">Questions/Comments:</label>
  <textarea name="speak"></textarea>      
  </fieldset>

  <fieldset>
  <input class="btn" name="submit" type="submit" value="Send Email" />
  <input class="btn" name="reset" type="reset" value="Clear Form" />
  </fieldset>

  <fieldset class="second">
  <h4>Would you like to be added to our mailing list?<h4>
  <input class="ckbox" type="checkbox" name="mailing" value="yes" checked="yes" /> Yes
  <input class="ckbox" type="checkbox" name="mailing" value="no" /> No
  </fieldset>

And these are the PHP codes:

<?php

$to = "shealtielyisrael@gmail.com";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = "Contact The SBOCC";


$fields = array();
$fields{"name"} = "name";
$fields{"email"} = "email";
$fields{"speak"} = "questions/comments";
$fields{"mailing"} = "newsletter";


$body = "We have received the following information:\n\n"; foreach($fields as $a => $b)
{$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }


$headers2 = "From: noreply@thesbocc.com";
$subject2 = "Thank you for contacting The SBOCC";
$autoreply = "Thank you for contacting us. Your question(s)/comment(s) has been     received. Shalom. Bless the comforter";

if($name == '') {print "You have not entered a name, please go back and try again";}
else {
 if($from == '') {print "You have not entered an email, please go back and try      again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: thankyou.html");}
else
{print "We encountered an error sending your mail, please notify shealtielyisrael@gmail.com";}
}
}

?>
4

1 回答 1

0

亲爱的,如果您正在使用 XAMPP 或 APPSERV 之类的本地服务器,或者您必须在本地计算机上安装邮件服务器

如果您在真实主机服务器上工作,请确保服务器中的 php 设置允许您使用邮件功能,因为许多服务器已停止此功能。

所以我建议你使用 smtp 发送邮件看看这里

http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm

并且有一个超级强大的库来发送电子邮件 PHPMailer

https://code.google.com/a/apache-extras.org/p/phpmailer/

于 2013-06-13T10:03:23.337 回答