【问题标题】:mail function is not working in localhost server邮件功能在本地主机服务器中不起作用
【发布时间】:2013-01-25 23:48:18
【问题描述】:

我在我的本地主机服务器上。我在下面使用此代码,但我从未收到过电子邮件。

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

【问题讨论】:

  • 您是否已将 SMTP 配置为通过 ISP 的邮件服务器发送电子邮件?
  • 我正在使用 XAMMP,你是怎么做到的?
  • 邮件功能在本地机器上不起作用

标签: php email localhost


【解决方案1】:

我知道有点晚了……

检查您的本地主机是否配置为发送电子邮件

在 ubuntu 终端上 尝试执行以下命令

# apt-get install sendmail

【讨论】:

    【解决方案2】:

    确保邮件服务器在 php.ini 文件中配置正确。

    在 php.ini 文件中像这样注释掉这些行并重新启动 Apache 服务器。

    /*[mail function]
    ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
    ; SMTP = localhost
    ; smtp_port = 25
    */
    
    /*; For Win32 only.
    ; http://php.net/sendmail-from
    ;sendmail_from = postmaster@localhost
    */
    

    【讨论】:

    • 你是怎么做到的?
    • 我遇到了这个网站,但是“将 localhost 更改为 ISP 的 smtp 服务器名称”实际上是什么意思 SMTP = smtp.wlink.com.np 这行是我所在的位置变得混乱
    • 您的 ISP 应该能够告诉您他们的 SMTP 地址。或者,如果您有 Gmail 帐户,则可以使用它:expertester.wordpress.com/2010/07/07/…
    • 他尝试使用xmpp的localhost邮件服务器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-16
    • 1970-01-01
    • 1970-01-01
    • 2012-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多