【问题标题】:Sending email from php on localhost在本地主机上从 php 发送电子邮件
【发布时间】:2012-08-21 23:58:54
【问题描述】:

我正在将 XAMPP 与 Mercury 和 Thunderbird 一起使用。当我通过 Mercury 发送消息时,消息工作正常,并且我在 Thunderbird 上收到了电子邮件。当我尝试使用 PHP 脚本时,它没有。

我确定它与 php 有关,但我无法找到解决它为什么不发送的解决方案。

我也没有收到任何错误,它表示消息已发送。

邮件测试.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

发送邮件.ini

smtp_server=localhost
smtp_port=25

【问题讨论】:

    标签: php email


    【解决方案1】:

    使用此 sendmail 程序与 SMTP 帐户(如 gmail 帐户)一起使用。这是主要项目站点http://glob.com.au/sendmail/,这是来自SO https://stackoverflow.com/a/11210090/209067的另一个答案的快速方法

    这就是我在本地 Windows 环境中的用途,我只是找不到完整的文章教程。

    【讨论】:

    • 我很确定这是我现在的问题,我需要授权我的用户名和密码。
    • 是的!!!!谢谢!我花了很多令人沮丧的时间试图弄清楚这一点,现在我明白了!
    猜你喜欢
    • 2016-07-22
    • 2013-04-16
    • 2014-10-25
    • 2013-10-01
    • 2010-12-19
    • 1970-01-01
    相关资源
    最近更新 更多