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

      • <bdo id='XZAjm'></bdo><ul id='XZAjm'></ul>

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

      2. <legend id='XZAjm'><style id='XZAjm'><dir id='XZAjm'><q id='XZAjm'></q></dir></style></legend>
      3. 如何在后台使用 PHPMailer 发送电子邮件?

        时间:2023-10-30

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

          <small id='2jXGt'></small><noframes id='2jXGt'>

            <tbody id='2jXGt'></tbody>
          <legend id='2jXGt'><style id='2jXGt'><dir id='2jXGt'><q id='2jXGt'></q></dir></style></legend>
              <bdo id='2jXGt'></bdo><ul id='2jXGt'></ul>

                  本文介绍了如何在后台使用 PHPMailer 发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  PHPMailers 在从 gmail 帐户发送电子邮件方面做得很好.但这需要相当长的时间,并且在发送电子邮件之前页面不会显示响应.有什么方法可以在后台发送电子邮件,以便为用户提供更好的用户体验?谢谢!

                  PHPMailers is doing a fine job in sending emails from a gmail account. But it takes quite a bit of time, and the page won't show the response until the email has been sent. Any ways to send the email in the background so that I can provide a better user experience to the user? Thanks!

                  推荐答案

                  使用 email queuephp exec() 是最好的方法之一.

                  它会在需要时触发(避免使用 CRON),它很快,因为它被称为后台,并且是即时的.

                  The use of an email queue and php exec() is one of the best ways.

                  It will trigger when needed (avoiding the use of CRONs), it's fast because it is called backgrounded, and immediate.

                  1.电子邮件队列.使用插入获取表的 MySQL 中的所有字段,例如:

                  1. Email queue. Take all fields in a table's MySQL with an insert, something like:

                  $queryIN="INSERT INTO email_queue (date,subject,body,destination,idle) values (...)";
                  mysql_query($queryIN);
                  

                  这很重要,因为您需要一个独立的后台进程,因此注册和审核所有外发电子邮件也是一个好主意.

                  That's important because you will need an independent background process, so also it's a good idea for registering and auditing all outgoing emails.

                  <强>2.PHP exec(). 在 MySQL 中插入之后是调用外部执行的时候了:

                  2. PHP exec(). After inserting in MySQL is time to call as external execution:

                  exec("wget -qO- http://example.com/index.php?process_email_queue=1 &> /dev/null &");
                  

                  • 注意,来自 wget -q0-&> 的选项.../dev/null & 需要抑制输出并作为后台进程调用.
                    • Take note, options from wget -q0- and &> ... /dev/null & are needed to suppress output and call as a background process.
                    • 3.用于处理队列调用的相同脚本文件 index.php 或其他:

                      这样,它会调用我们的index.php(你可以使用其他名称文件),并处理传出:

                      This way, it will call our index.php (you can use other name file), and process outgoing:

                      if ($_GET['process_email_queue']==1) { ...code for sending idle emails queue...  }
                      

                      也许您必须为 exec() 触摸一些 php.ini 选项,这没什么大不了的.

                      Perhaps you have to touch some php.ini options for exec(), is not a big deal.

                      一旦一切正常运行,您将提供更好的网络导航和电子邮件处理,以实现快速响应和零等待.

                      Once everything is running correctly, you will offer a better web navigation and email handling for fast response and zero waits.

                      在某些情况下,您将从直接电子邮件等待 2.60 秒到 queue-exec-background 0.024 秒,速度提高了 11 倍.

                      这篇关于如何在后台使用 PHPMailer 发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:从 Perl 在后台运行作业而不等待返回 下一篇:Windows机器上的PHP;在后台启动进程

                  相关文章

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

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

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

                      <legend id='VgJ3Z'><style id='VgJ3Z'><dir id='VgJ3Z'><q id='VgJ3Z'></q></dir></style></legend>