在本地主机上从php发送电子邮件

在本地主机上从php发送电子邮件,php,email,Php,Email,我正在使用XAMPP和Mercury和Thunderbird。当我通过Mercury发送消息时,消息工作正常,我通过Thunderbird接收电子邮件。当我尝试使用PHP脚本时,它不会 我确信它与php有关,但我还没有找到一个解决方案来解释为什么它不发送 我也没有收到任何错误,它说消息已经发送了 mailtest.php: $to = "patrick@localhost"; $subject = "hi"; $body="text".PHP_EOL; $body.="this message

我正在使用XAMPP和Mercury和Thunderbird。当我通过Mercury发送消息时,消息工作正常,我通过Thunderbird接收电子邮件。当我尝试使用PHP脚本时,它不会

我确信它与php有关,但我还没有找到一个解决方案来解释为什么它不发送

我也没有收到任何错误,它说消息已经发送了

mailtest.php:
$to = "patrick@localhost";
$subject = "hi";
$body="text".PHP_EOL;
$body.="this message was sent".PHP_EOL;
$headers = "From: postmaster@localhost";

if (mail($to, $subject, $body, $headers)) {
    echo "message sent!";
    } 
    else {
        echo "failed";
    }   
?>
php.ini:

[mail function]

; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost
smtp_port = 25

; I am on Windows 7 64bit
; For Win32 only.
; http://php.net/sendmail-from
; sendmail_from = localhost
sendmail.ini

smtp_server=localhost
smtp_port=25

使用此sendmail程序与SMTP帐户(如gmail帐户)一起使用。这里是主要的项目现场,这里是一个快速如何从另一个答案,所以


这是我在本地windows环境中使用的工具,我只是找不到完整的文章教程来学习它。

使用此sendmail程序与SMTP帐户(如gmail帐户)一起使用。这里是主要的项目现场,这里是一个快速如何从另一个答案,所以


这是我在本地windows环境中使用的工具,我只是找不到学习该工具的完整文章教程。

我很确定这是我现在的问题,我需要授权我的用户名和密码。是的!!!!非常感谢。我花了很多令人沮丧的时间试图弄明白这一点,现在我明白了!我很确定这是我现在的问题,我需要授权我的用户名和密码。是的!!!!非常感谢。我花了很多令人沮丧的时间试图弄明白这一点,现在我明白了!