php function mail()表示发送电子邮件但从未收到过电子邮件

时间:2015-02-12 16:08:37

标签: php forms email

编辑:有人将此标记为重复问题,但在审核了另一个帖子后(并遵循John Conde的每一步回答)但我仍然无法使mail()函数正常工作。我非常愿意提供一些帮助,而不仅仅是将我重定向到别人的线程......

我正在使用PHP函数Mail()在有人填写我们的联系表单后向我的老板和我发送电子邮件。我在我们网站上的其他两个联系表单中使用了相同的代码(仅更改了主题和标题重定向位置),并且它对这两种联系表单都可以正常工作,但由于某种原因,这种表单不起作用。这是我的电子邮件相关代码(这不是我的整个PHP脚本,但如果它有帮助我可以发布它。如果你看到“删除”我出于安全原因删除了真实内容)。

    $email_from = $Email;
    $email_subject = "3D Part Finishing Contact Form";
    $email_body = '<html><body>';
    $email_body .= '<table border="1" cellpadding="15">';
    $email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Name:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $FName . " " . $LName . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Company:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Company . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Email Address:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Email . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Secondary Email Address:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Email2 . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Street:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Street . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>City:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $City . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>State:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $State . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Country:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Country . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Zipcode:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Zipcode . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Phone:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Phone1 . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Fax:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Fax . "</td></tr>";
    $email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Message:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Message . "</td></tr>";
    $email_body .= "</table>";
    $email_body .= "</body></html>";

    $rbailey = "removed";
    $info = "removed";
    $headers = "From: $email_from \r\n";
    $headers .= "Reply-To: $Email \r\n";
    $headers .= 'X-Mailer: PHP/' . phpversion();
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    if(mail($rbailey,$email_subject,$email_body,$headers)){
        echo "     Email sent to Rbailey";  
    } else {
        echo "     Email not sent to Rbailey";  
    }
    if(mail($info,$email_subject,$email_body,$headers)){
        echo "     Email sent to Info"; 
    } else {
        echo "     Email not sent to Info"; 
    }

    header('location:Contact.php');
}

我已经确认,在提交表单时,它会将数据插入我们的数据库并发送电子邮件(两个mail()函数echo“发送给Info / Rbailey的电子邮件”)。虽然我的网站说这两封电子邮件都没有发送,但邮件都没有收到邮件(是的,我已经检查过垃圾邮件垃圾邮件文件夹了)

提前感谢您的帮助!

0 个答案:

没有答案