dqqyp90576 2014-03-17 12:35
浏览 35
已采纳

HTML5 / PHP表单突然不会发送邮件

Basically this was working correctly a couple days ago and I tested it again on MAMP today and I'm no longer receiving the emails so mail() isn't firing? Please help.

This is my form in my index page

<form method="POST" action="form.php">

<label>Name</label>
<input name="name" placeholder="Full Name" required>
<label>Email</label>
<input name="email" type="email" placeholder="Email Address" required>    
<label>Company</label>
<input name="company" type="text" placeholder="Your Company" required>    
<input  type="hidden" name="robots" value="" required/>
<input id="submit" name="submit" type="submit" value="Submit">

</form>

and this is my external form.php file

<?php
$name = mysql_real_escape_string(strip_tags($_POST['name']));
$email = mysql_real_escape_string(strip_tags($_POST['email']));
$company = mysql_real_escape_string(strip_tags($_POST['company']));
$robots = mysql_real_escape_string(strip_tags($_POST['robots']));
$from = 'From:RegisterForm'; 
$to = 'sofi.smith@blah.com';
$subject = 'Lead';

$body = "From: $name
 E-Mail: $email
 company: $company
 ";

if($_POST['submit']) {
 if($robots == '') {
    if (mail($to, $subject, $body, $from)) {
    header('Location: thank-you-page.html');
    } else {
        echo '<p>Something went wrong, please try again</p>'; 
    }
} else  {
    echo 'Sorry, we don\'t like spammers here!';
}
}

?><!doctype html>
<head>
<meta charset="UTF-8">
<title>Form</title>
</head>
<body>
</body>
</html>

Mamp php log shows no errors in the log apart from the depreciated element and when I remove this it makes no difference? MAMP php error log

  • 写回答

1条回答 默认 最新

  • dtzhfb4869 2014-03-17 12:39
    关注
    1. Use correct mail headers From: XXX is incorrect Use From: XXX . A Name-Value Pair of a valid header is Name: Value

    2. use an PHPMailer-Class

    3. Mails wont send? Your server is not configurated for sending mails. Contact the server admin!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题