1

可能重复:
hotmail.com 未收到邮件

我的网站上有这个简单的表格,当它发送到我的 Hotmail 帐户时,我没有收到电子邮件,甚至没有收到垃圾文件夹。

这是表单代码:

<form action="mail.php" method="POST">
    <p><label title="Name">Name:</label><br />
        <input type="text" name="name" autocomplete="on" required="required"></p>
    <p><label title="Email">Email:</label><br />
        <input type="text" name="email" autocomplete="on" required="required"></p>
    <p><label title="About">My message is about...</label><br />
        <select name="about">
            <option value="general">General Query</option>
            <option value="wedding">Wedding</option>
            <option value="corporate">Corporate Event or Trade Show</option>
            <option value="other">Other Event</option>
        </select>
    <p><label title="Message">Message:</label><br />
        <textarea name="message" rows="6" cols="25" required="required"></textarea></p>
    <input type="submit" value="Send">
</form>

和 mail.php 文件:

<?php 
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $about = $_POST['about'];
        $formcontent="From: $name \n About: $about \n Message: $message";
        $recipient = "MyEmailAddress@Live.co.uk";
        $subject = "Contact Form";
        $mailheader = "Reply-To: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You!";
?>

我最终确实看到了一个带有“谢谢!”的页面。显示但未收到电子邮件。

4

2 回答 2

3

邮件递送是一项棘手的业务……仅仅因为您发送邮件并不意味着任何人都会收到它。如果传入的邮件不符合某些标准,许多接收服务器会简单地忽略它(根据我的经验,Gmail 和 Hotmail 特别容易默默地拒绝传递,因此它甚至不会成为垃圾邮件)。有几件事可以确保您已完成:

1) 您在 DNS 记录中设置了 PTR/ SPF(反向查找)条目

2) 确保您不在任何黑名单上 ( http://www.mxtoolbox.com/blacklists.aspx )

3)展开你的标题

$headers = "MIME-Version: 1.0\r\n"
          ."Content-Type: $contentType; charset=utf-8\r\n"
          ."Content-Transfer-Encoding: 8bit\r\n"
          ."From: =?UTF-8?B?". base64_encode("Your sending display name") ."?= <$from>\r\n"
          ."Reply-To: $replyTo\r\n"
          ."X-Mailer: PHP/". phpversion();

但是,如果您真的想确保邮件通过,请通过 SMTP发送邮件。您永远无法保证邮件的传递,但它会更加可靠。如果您不发送大量邮件,您可以尝试使用Mandrill或类似服务为您中继电子邮件。

于 2012-12-15T19:31:38.113 回答
0

您可以使用以下方法。成功时返回 true。

function sendMail($email, $subject, $message)
{
    $supportEmail = 'info@abc.com';
    $from = 'Abc';
    $msg  = $message;
    $from = str_replace(' ', '-', $from);
    $frm  = $from.' <'.$supportEmail.'>';
    preg_match("<(.*)@(.*\..*)>", $frm, $match);

    ///////////////////Headers/////////////////
    $hdr='';
    $hdr.='MIME-Version: 1.0'."\n";
    $hdr.='content-type: text/html; charset=iso-8859-1'."\n";
    $hdr.="From: {$frm}\n";
    $hdr.="Reply-To: {$frm}\n";
    $hdr.="Message-ID: <".time()."@{$match[2]}>\n";
    $hdr.='X-Mailer: PHP v'.phpversion();
    $x=@mail($email, $subject, $msg, $hdr);
    if($x==0)
    {
        $email=str_replace('@','\@', $email);
        $hdr=str_replace('@','\@',$hdr);
        $x=@mail($email, $subject, $msg, $hdr);
    }
    return $x;
}
于 2012-12-15T19:40:02.980 回答