<bdo id='bl1Oq'></bdo><ul id='bl1Oq'></ul>

      1. <i id='bl1Oq'><tr id='bl1Oq'><dt id='bl1Oq'><q id='bl1Oq'><span id='bl1Oq'><b id='bl1Oq'><form id='bl1Oq'><ins id='bl1Oq'></ins><ul id='bl1Oq'></ul><sub id='bl1Oq'></sub></form><legend id='bl1Oq'></legend><bdo id='bl1Oq'><pre id='bl1Oq'><center id='bl1Oq'></center></pre></bdo></b><th id='bl1Oq'></th></span></q></dt></tr></i><div id='bl1Oq'><tfoot id='bl1Oq'></tfoot><dl id='bl1Oq'><fieldset id='bl1Oq'></fieldset></dl></div>

        <small id='bl1Oq'></small><noframes id='bl1Oq'>

      2. <legend id='bl1Oq'><style id='bl1Oq'><dir id='bl1Oq'><q id='bl1Oq'></q></dir></style></legend><tfoot id='bl1Oq'></tfoot>

      3. PHP xampp mail()函数不起作用

        时间:2024-04-12
          <bdo id='LcnYy'></bdo><ul id='LcnYy'></ul>

        • <small id='LcnYy'></small><noframes id='LcnYy'>

            <tfoot id='LcnYy'></tfoot>
              <tbody id='LcnYy'></tbody>
                <legend id='LcnYy'><style id='LcnYy'><dir id='LcnYy'><q id='LcnYy'></q></dir></style></legend>

                  <i id='LcnYy'><tr id='LcnYy'><dt id='LcnYy'><q id='LcnYy'><span id='LcnYy'><b id='LcnYy'><form id='LcnYy'><ins id='LcnYy'></ins><ul id='LcnYy'></ul><sub id='LcnYy'></sub></form><legend id='LcnYy'></legend><bdo id='LcnYy'><pre id='LcnYy'><center id='LcnYy'></center></pre></bdo></b><th id='LcnYy'></th></span></q></dt></tr></i><div id='LcnYy'><tfoot id='LcnYy'></tfoot><dl id='LcnYy'><fieldset id='LcnYy'></fieldset></dl></div>

                  本文介绍了PHP xampp mail()函数不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 php (xampp) 从我的 gmail 帐户发送电子邮件.我在 stackoverflow 上搜索,当我得到东西时,我将 xampp 的文件 sendmail.ini 和 php.ini 更改为,

                  I am trying to send emails from my gmail account using php (xampp). I search over stackoverflow and as I got the things I changed my xampp's files sendmail.ini and php.ini as,

                  在 C:xamppphpphp.ini 中,我从 extension=php_openssl.dll 行的开头删除了分号,以使 SSL 对本地主机的 gmail 起作用.

                  In C:xamppphpphp.ini I removed the semicolon from the beginning of the line extension=php_openssl.dll to make SSL working for gmail for localhost.

                  在[邮件功能]下的php.ini文件中我改了

                  in php.ini file under [mail function] I changed

                  SMTP=smtp.gmail.com
                  smtp_port=25
                  sendmail_from = mukul.agrawal19@gmail.com
                  sendmail_path = ""C:xamppsendmailsendmail.exe" -t"
                  

                  然后在 C:xamppsendmailsendmail.ini 中.我用以下代码替换了 sendmail.ini 中的所有现有代码

                  Then in C:xamppsendmailsendmail.ini. I replaced all the existing code in sendmail.ini with following code

                  [sendmail]
                  
                  smtp_server=smtp.gmail.com
                  smtp_port=25
                  error_logfile=error.log
                  debug_logfile=debug.log
                  auth_username=mukul.agrawal19@gmail.com
                  auth_password=my-gmail-password
                  force_sender=mukul.agrawal19@gmail.com
                  

                  然后我写了一个简单的邮件函数

                  then I wrote a simple mail function

                  <?php
                  $to = 'mukulagrawal13@live.com';
                  $subject = 'Test email'; 
                  $message = "Hello World!
                  
                  This is my first mail."; 
                  $headers = "From: mukul.agrawal19@gmail.com
                  Reply-To: mukul.agrawal19@gmail.com";
                  $mail_sent = @mail( $to, $subject, $message, $headers );
                  echo $mail_sent ? "Mail sent" : "Mail failed";
                  ?>
                  

                  然后通过我的浏览器进入此页面,收到邮件失败的回声.

                  then went on the this page by my browser, got echo as Mail Failed.

                  我看到了我的调试文件,我得到了

                  I saw my debug file and I got

                  14/12/03 18:24:00 ** --- MESSAGE BEGIN ---
                  14/12/03 18:24:00 ** To: mukulagrawal13@live.com
                  14/12/03 18:24:00 ** Subject: Test email
                  14/12/03 18:24:00 ** From:mukul.agrawal19@gmail.com
                  14/12/03 18:24:00 ** Reply-To:mukul.agrawal19@gmail.com
                  14/12/03 18:24:00 ** 
                  14/12/03 18:24:00 ** Hello World!
                  14/12/03 18:24:00 ** 
                  14/12/03 18:24:00 ** This is my first mail.
                  14/12/03 18:24:00 ** --- MESSAGE END ---
                  14/12/03 18:24:01 ** Connecting to smtp.gmail.com:25
                  14/12/03 18:24:08 ** Connected.
                  14/12/03 18:24:08 << 220 mx.google.com ESMTP o17sm23150442pdn.33 - gsmtp<EOL>
                  14/12/03 18:24:08 >> EHLO Mukul-PC<EOL>
                  14/12/03 18:24:10 << 250-mx.google.com at your service, [223.186.182.29]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
                  14/12/03 18:24:10 ** Authenticating as mukul.agrawal19@gmail.com
                  14/12/03 18:24:10 >> STARTTLS<EOL>
                  14/12/03 18:24:12 << 220 2.0.0 Ready to start TLS<EOL>
                  14/12/03 18:24:14 >> QUIT<EOL>
                  
                  lots of codes in unknown language.
                  
                  14/12/03 18:21:47 ** Disconnected.
                  14/12/03 18:21:47 ** Disconnecting from smtp.gmail.com:25
                  14/12/03 18:21:47 ** Disconnected.
                  14/12/03 18:21:47 ** Disconnected.
                  14/12/03 18:21:47 ** Connection Closed Gracefully.
                  

                  我不明白这是什么问题.

                  I am not getting whats the problem.

                  推荐答案

                  好的,我搞定了.不幸的是,不使用 TLS,因为端口 587 在我们的网络中被阻止,所以我不得不使用端口 465.但我希望 TLS 也可以工作.

                  Ok, I got this working. Unfortunately not with TLS, because Port 587 is blocked in our network so I had to use Port 465. But I expect that TLS will also work.

                  我使用的是 XAMPP 5.6.3.

                  I used XAMPP 5.6.3.

                  发送邮件配置:

                  [sendmail]
                  smtp_server=smtp.gmail.com
                  smtp_port=465
                  smtp_ssl=auto
                  error_logfile=error.log
                  debug_logfile=debug.log
                  auth_username==*****@gmail.com
                  auth_password=*********
                  force_sender=*****@gmail.com
                  

                  PHP 配置:

                  [mail function]
                  SMTP=smtp.gmail.com
                  smtp_port=465
                  sendmail_from = *****@gmail.com
                  sendmail_path = ""c:xamppsendmailsendmail.exe" -t"
                  

                  代码:

                  <?php
                  $to = 'repicient@example.com';
                  $subject = 'Test email'; 
                  $message = "Hello World!
                  
                  This is my first mail."; 
                  $headers = "From: *****@gmail.com
                  Reply-To: *****@gmail.com";
                  $mail_sent = @mail( $to, $subject, $message, $headers );
                  echo $mail_sent ? "Mail sent" : "Mail failed";
                  ?>
                  

                  重要:

                  您需要在 GMAIL 中启用 SMTP 访问,还需要允许不安全的客户端:

                  You will need to enable SMTP access in GMAIL, also you need to allow unsecure clients:

                  https://www.google.com/settings/security/lesssecureappshttps://support.google.com/mail/answer/75726

                  请注意,您要使用的 smtp 端口已在防火墙中打开!我建议尝试使用 Thunderbird 从您的开发机器进行连接检查.然后你知道客户端是否能够连接.

                  Be aware that the smtp port you want to use is open in your firewall! I suggest to try a connection check from your dev machine with thunderbird. Then you know if the client is able to connect.

                  这是我的结果:

                  14/12/03 12:19:32 ** --- MESSAGE BEGIN ---
                  14/12/03 12:19:32 ** To: *****@example.com
                  14/12/03 12:19:32 ** Subject: Test email
                  14/12/03 12:19:32 ** From: ******@gmail.com
                  14/12/03 12:19:32 ** Reply-To: ******@gmail.com
                  14/12/03 12:19:32 ** 
                  14/12/03 12:19:32 ** Hello World!
                  14/12/03 12:19:32 ** 
                  14/12/03 12:19:32 ** This is my first mail.
                  14/12/03 12:19:32 ** --- MESSAGE END ---
                  14/12/03 12:19:34 ** Connecting to smtp.gmail.com:465
                  14/12/03 12:19:34 ** Connected.
                  14/12/03 12:19:34 << 220 mx.google.com ESMTP pl1sm22468617wic.16 - gsmtp<EOL>
                  14/12/03 12:19:34 >> EHLO vm-test-03.devnet.local<EOL>
                  14/12/03 12:19:35 << 250-mx.google.com at your service, [xxx.xxx.xxx.xxx]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
                  14/12/03 12:19:35 ** Authenticating as ****@gmail.com
                  14/12/03 12:19:35 >> AUTH LOGIN<EOL>
                  14/12/03 12:19:35 << 235 2.7.0 Accepted<EOL>
                  14/12/03 12:19:35 >> MAIL FROM: <*****@gmail.com><EOL>
                  14/12/03 12:19:35 << 250 2.1.0 OK pl1sm22468617wic.16 - gsmtp<EOL>
                  14/12/03 12:19:35 >> RCPT TO: <repicient@example.com.de><EOL>
                  14/12/03 12:19:35 << 250 2.1.5 OK pl1sm22468617wic.16 - gsmtp<EOL>
                  14/12/03 12:19:35 >> DATA<EOL>
                  14/12/03 12:19:35 << 354  Go ahead pl1sm22468617wic.16 - gsmtp<EOL>
                  14/12/03 12:19:35 >> Date: Wed, 3 Dec 2014 12:19:35 -0800<EOL>
                  14/12/03 12:19:35 >> To: repicient@example.com<EOL>
                  14/12/03 12:19:35 >> Subject: Test email<EOL>
                  14/12/03 12:19:35 >> From: *****@gmail.com<EOL>
                  14/12/03 12:19:35 >> Reply-To: *****@gmail.com<EOL>
                  14/12/03 12:19:35 >> <EOL>
                  14/12/03 12:19:35 >> Hello World!<EOL>
                  14/12/03 12:19:35 >> <EOL>
                  14/12/03 12:19:35 >> This is my first mail.<EOL>
                  14/12/03 12:19:35 >> .<EOL>
                  14/12/03 12:19:36 << 250 2.0.0 OK 1417637977 pl1sm22468617wic.16 - gsmtp<EOL>
                  14/12/03 12:19:36 >> QUIT<EOL>
                  14/12/03 12:19:36 << 221 2.0.0 closing connection pl1sm22468617wic.16 - gsmtp<EOL>
                  14/12/03 12:19:36 ** Disconnecting from smtp.gmail.com:465
                  14/12/03 12:19:36 ** Disconnected.
                  14/12/03 12:19:36 ** Disconnected.
                  

                  这篇关于PHP xampp mail()函数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何保存扩展名为 .php 或 .html 的 PHP 文件? 下一篇:Wordpress 和 Xampp 不打开子页面

                  相关文章

                  1. <small id='k75cx'></small><noframes id='k75cx'>

                    <legend id='k75cx'><style id='k75cx'><dir id='k75cx'><q id='k75cx'></q></dir></style></legend>
                    <i id='k75cx'><tr id='k75cx'><dt id='k75cx'><q id='k75cx'><span id='k75cx'><b id='k75cx'><form id='k75cx'><ins id='k75cx'></ins><ul id='k75cx'></ul><sub id='k75cx'></sub></form><legend id='k75cx'></legend><bdo id='k75cx'><pre id='k75cx'><center id='k75cx'></center></pre></bdo></b><th id='k75cx'></th></span></q></dt></tr></i><div id='k75cx'><tfoot id='k75cx'></tfoot><dl id='k75cx'><fieldset id='k75cx'></fieldset></dl></div>
                  2. <tfoot id='k75cx'></tfoot>
                      <bdo id='k75cx'></bdo><ul id='k75cx'></ul>