使用PHP邮件发送的邮件未显示

时间:2014-12-21 21:33:40

标签: php email debian sendmail

我在Debian 7.0上使用PHP 5.4.35-0 + deb7u2。我使用以下PHP代码发送消息。

    $to = $emailAddress;
    $subject = "Registration";
    $message = "Dear " . $firstname . " " . $lastName .",\n\n" .
        "Thank you for registering for our program.\n\n" .
        "To complete your registration, please confirm your registration using the following activation code.\n\n" .
        $randomActivationCode . "\n\n" . 
        "at the following link.\n\n" . $Link . "\n\n" .
        "If you did not register for our program, please accept our apologies and disregard this message\n\n" .
        "Have a wonderful day!\nCompany name.\n";

    $from = "me@yahoo.com";
    $headers = "From:" . $from;

    $mailDelivery=mail($to,$subject,$message,$headers);
    if ($mailDelivery)
    {
        ?>
        <script type="text/javascript">
        document.location.href="http://home.com/Prewelcome.php";
        </script>
        <script type="text/javascript">
        alert("Thank you for your interest in our program.\nTo complete your registration, please check your email.");
        document.location.href="Subscriptions.php";
        </script>
        <?php
    }
    else
    {
        ?>
        <script type="text/javascript">
        alert("Mail delivery failed");
        </script>
        <?php
    }

我收到警告框&#34;感谢您对我们的计划感兴趣。\ n要完成注册,请查看您的电子邮件。&#34;但电子邮件永远不会出现。 (我使用我的电子邮件地址作为收件人。)

我还编辑了php.ini并确保

sendmail_path = /usr/sbin/sendmail
包含

并且/ usr / sbin / sendmail存在。执行此操作后,我还使用

重新启动了apache
sudo /etc/init.d/apache2 restart

我也做了以下测试

sendmail me@gmail.com
从命令行

,邮件确实显示在我的邮箱中。

我也跑了

sudo cat /var/log/apache2/error.log

并且没有错误。

然而,我从我的php文件发送的邮件从未显示在我的邮箱中。

0 个答案:

没有答案