douju6850 2013-12-09 16:52
浏览 14
已采纳

PHP正在加载,但没有向我发送电子邮件

I will admit that I am not the best at PHP, but what I am doing usually works well enough for me because the clients just need the information sent to their emails, and the security question works well enough to keep spam away from their inbox. But for some reason, this code will not work and I cannot figure out why. This same code with different variables is on another site I have and is tested and working. Does anyone have any advice?

<form action="submit_form.php" method="POST" >
<p>Name<br /><input type="text" name="name" required /></p>
<p>Email Address<br /><input type="text" name="email" required /></p>
<p>Phone Number<br /><input type="text" name="phone" required /></p>
<p>County<br /><input type="text" name="county" required /></p>
<p>Annual Income<br /><input type="text" name="income" required /></p>
<p>What is 4 + 1? (anti-spam)<br /><input type="text" name="answer" required /></p>
<input type="submit" value="Take The First Step" />
</form>

<?php # BOOST
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$county = $_POST['county'];
$income = $_POST['income'];
$correct_answer = '5';
$answer = $_POST['answer'];

if ($correct_answer != $answer) {

die("You're not a valid user of this site!");

}
else {


$to = "glenn@boostbizseo.com";
$subject = "USDA LOANS";
$message = "USDA LOANS:

Name: $name
Email: $email
Phone: $phone
County: $county
Annual Income: $income";
$from = "USDA Loans";
mail($to,$subject,$message,$headers);
echo "Thank you for getting in contact with us. We will be in contact with you soon          regarding your USDA Loan! <a href=http://www.usdaloansmo.com>Click Here</a> to go back to our website!";
}
?>
  • 写回答

3条回答 默认 最新

  • duanquanzhi5560 2013-12-09 17:01
    关注
        $from = "someonelse@example.com"; //email ID
        $headers = "From:" . $from;
    
    
        mail($to,$subject,$message,$headers);
    

    I believe this will work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?