表单不会向某些地址发送电子邮件

时间:2011-04-20 19:02:28

标签: php forms

我的简单表单脚本总是发送到我以前的电子邮件地址,现在不发送给我的新邮件。是因为地址中有破折号吗?这是脚本:

<?php 

if ($_POST["email"] <> '') {
    $ToEmail = 'info@xxx-xxx.com';
    $EmailSubject = 'Site contact form '; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=utf-8\r\n"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
    $MESSAGE_BODY .= "Telephone: ".$_POST["tel"]."<br>";
    $MESSAGE_BODY .= "Type: ".$_POST["type"]."<br>";
    $MESSAGE_BODY .= "Subject: ".$_POST["subject"]."<br>";
    $MESSAGE_BODY .= "Hours per week: ".$_POST["hours"]."<br>";
    $MESSAGE_BODY .= "Additional information: ".nl2br($_POST["info"])."<br>"; 

    // HAS THE SPAM TRAP FIELD BEEN FILLED IN?

    if( !empty( $_POST['random'] ) )
    {exit;}

    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 

?> 

<html>

    <h3>Thank you for your email</h3>
    <h4>I'll get back to you as soon as possible</h4>
    <a href="index.html"><p>Click here to go back to the home page</p></a>

</html>


<?php 
} else { 
?> 

<html>Sorry, this form didn't work</html>

任何帮助将不胜感激。感谢

2 个答案:

答案 0 :(得分:0)

它可能会被接收端的垃圾邮件过滤器捕获。将脚本中的发件人电子邮件地址添加到新电子邮件的白名单中,看看是否有帮助。

答案 1 :(得分:0)

您是否已从Gmail迁移到Yahoo帐户?破折号应该没有任何区别。某些电子邮件提供商(尤其是Yahoo)在使用mail命令发送电子邮件时遇到问题。