繁体   English   中英

PHP的发送邮件本地不醒?

[英]php send mail local not woking?

我试图在本地主机中发送邮件。

但是工作。 我改变了php.ini

       [mail function]
        SMTP=SMTP.gmail.com
        smtp_port =587
        sendmail_from =postmaster@testmail.com
       sendmail_path = "C: \xampp\sendmail.exe\" -t"

这是我的PHP邮件功能

          public function sendMail($to,$subject,$from=null,$headers = null)
            {
              if($headers == null) {
               $headers = $this->setMimes();
                 }
               $headers .= $this->setFrom($from);
                return mail($to,$subject,$this->getMessage(),$headers);
           }

此邮件未发送。

要检查/更改您的PHP邮件配置:

打开您的php.ini文件(如果您不知道它在哪里,请参阅下文)搜索显示为[mail function]的行。添加/更改您的邮件服务器的详细信息。 这可能是本地邮件服务器或ISP的邮件服务器。 保存/关闭php.ini文件重新启动Web服务器

首次打开php.ini文件时,邮件设置的示例:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

其他信息在echo phpinfo()中,您可以查看您的PHP配置详细信息。 您可以通过创建带有以下行的.php文件来实现此目的:。 在浏览器中运行此命令时,将看到完整的PHP配置变量列表。 只需搜索包含php.ini和sendmail_path的行即可查看您需要使用的值。

另一个想法是,您可以使用ini_set()像这样正确配置您的邮件设置

如果您的邮件脚本继续失败,请在电子邮件脚本的顶部添加以下代码。

// Please specify your Mail Server - Example: mail.example.com.
ini_set("SMTP","mail.example.com");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");

// Please specify the return address to use
ini_set('sendmail_from', 'example@YourDomain.com');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM