简体   繁体   English

PHP的发送邮件本地不醒?

[英]php send mail local not woking?

I tried to send mail in localhost. 我试图在本地主机中发送邮件。

but working. 但是工作。 i change the php.ini 我改变了php.ini

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

this my php mail function 这是我的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);
           }

this mail not sending. 此邮件未发送。

To check/change your PHP mail configuration: 要检查/更改您的PHP邮件配置:

Open your php.ini file (if you don't know where this is, see below) Search for the line that reads [mail function] Add/change the details of your mail server. 打开您的php.ini文件(如果您不知道它在哪里,请参阅下文)搜索显示为[mail function]的行。添加/更改您的邮件服务器的详细信息。 This could be a local mail server or the mail server of your ISP. 这可能是本地邮件服务器或ISP的邮件服务器。 Save/close the php.ini file Restart your web server 保存/关闭php.ini文件重新启动Web服务器

An example of what the mail settings could look like when you first open the php.ini file: 首次打开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 =

Additional info is in echoing phpinfo() you can view your PHP configuration details. 其他信息在echo phpinfo()中,您可以查看您的PHP配置详细信息。 You can do this by creating a .php file with the following line on it: . 您可以通过创建带有以下行的.php文件来实现此目的:。 When you run this in your browser, you will see a full list of PHP configuration variables. 在浏览器中运行此命令时,将看到完整的PHP配置变量列表。 Simply search for the lines that contain php.ini and sendmail_path to see the values you need to use. 只需搜索包含php.ini和sendmail_path的行即可查看您需要使用的值。

Another idea is you might use ini_set() to properly config your mail setting like this 另一个想法是,您可以使用ini_set()像这样正确配置您的邮件设置

Add the following code to the top of your email script if your mail script continues to fail. 如果您的邮件脚本继续失败,请在电子邮件脚本的顶部添加以下代码。

// 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