在Gmail下永远不会收到php邮件

时间:2016-05-10 15:44:01

标签: php email

我是php新手,我正在尝试发送确认电子邮件:

public static function sendAuthenticationEmail($username, $email, $uuid) {
    $subject = "Register email address";
    $headers = 'MIME-Version: 1.0' . PHP_EOL . 
               'Content-type: text/html; charset=iso-8859-1' . PHP_EOL . 
               'To: ' . $username . ' <' . $email . '>' . PHP_EOL . 
               'From: whereisthemonkey <noreply@whereisthemonkey.me>' . PHP_EOL .
               'X-Mailer: PHP/' . phpversion();
    $link = 'http://localhost/Whereisthemonkey/FileSystem/EmailSystem.php?email=' .
            $email . '&uuid=' . substr($uuid, 0, 14);
    $message = '
        <html>
            <head>
                <title>Email authentication</title>
            </head>
            <body style="color: #000080">
                <p style="font-weight: bold; color: #990000">Do not reply to the email!</p>
                <p>Hey ' . $username . ', this email has recently been used as authentication on <b>Whereisthemonkey</b>!<br><br>
                If that was you, please click 
                <a href="' . $link . '">here</a><br><br>
                <p>If that was not you, please just ignore this email!</p>
                <p>Have a nice day, the whereisthemonkey team!
            </body>';
    return mail($email, $subject, $message, $headers);
}

邮件已发送,但从未到达服务器(在本例中为gmail)。

我做错了什么?

非常感谢, 卢卡斯!

1 个答案:

答案 0 :(得分:2)

也许Gmail会将您的服务器IP地址列入黑名单,或者电子邮件会转到您的垃圾邮件文件夹。

尝试将相同的代码放在不同的服务器中或使用SMTP连接。