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

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

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

      1. <tfoot id='CMXaS'></tfoot>

        发送邮件而不阻止“执行"

        Send mail without blocking #39;execution#39;(发送邮件而不阻止“执行)
      2. <legend id='eia8F'><style id='eia8F'><dir id='eia8F'><q id='eia8F'></q></dir></style></legend>
          <tbody id='eia8F'></tbody>
        <i id='eia8F'><tr id='eia8F'><dt id='eia8F'><q id='eia8F'><span id='eia8F'><b id='eia8F'><form id='eia8F'><ins id='eia8F'></ins><ul id='eia8F'></ul><sub id='eia8F'></sub></form><legend id='eia8F'></legend><bdo id='eia8F'><pre id='eia8F'><center id='eia8F'></center></pre></bdo></b><th id='eia8F'></th></span></q></dt></tr></i><div id='eia8F'><tfoot id='eia8F'></tfoot><dl id='eia8F'><fieldset id='eia8F'></fieldset></dl></div>

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

            <tfoot id='eia8F'></tfoot>

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

                1. 本文介绍了发送邮件而不阻止“执行"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Zend Framework 应用程序中使用 Zend_Mail 发送包含基于 Web 的联系表单内容的电子邮件.

                  邮寄本身工作正常(我使用的是 Google Apps 帐户),但处理时间可能相当长(从几秒到近一分钟不等).

                  我的控制器操作通常会在发送邮件后重定向访问者,所以我想我可以在调用 $mail->send() 之前重定向访问者,并让脚本在后台"继续:

                  所以我尝试了以下方法:

                  $mailView = clone $this->view;$mailView->assign('name', $form->getValue('name'));$mailView->assign('email', $form->getValue('email'));$mailView->assign('message', $form->getValue('message'));$mailContent = $mailView->render('mailContact.phtml');$mail = new Zend_Mail();$mail->addTo('recipient@domain.com');$mail->setSubject('网络联系人');$mail->setBodyHtml($mailContent, 'UTF-8');$this->_flashMessenger->addMessage('感谢您的留言!');$this->_redirector->setExit(false)->gotoUrl('/about/contact');$mail->send();

                  其中 $this->_redirector 是 *Zend_Controller_Action_Helper_Redirector* 的一个实例

                  这似乎没有什么区别,在发送邮件时脚本仍然被阻止,然后发生重定向.

                  也许我应该写一个控制器插件,使用 postDispatch() 钩子可以让我在访问者被重定向后发送邮件吗?

                  欢迎提出建议!

                  解决方案

                  为什么不试试这个:

                  1. 加载视图
                  2. 调用 Ajax 脚本从将加载的视图中负责的控制者发送电子邮件.

                  I'm using Zend_Mail in a Zend Framework application to send an e-mail with the contents of a web-based contact form.

                  The mailing itself works fine ( im using a Google Apps account ) but it can take fairly long to process ( ranging from a few seconds to nearly a minute ).

                  My controler action would normally redirect the visitor after sending the mail, so I thought I might be able to redirect the visitor prior to calling $mail->send() and let the script continue in the 'background':

                  So I tried the following:

                  $mailView = clone $this->view;
                  $mailView->assign('name', $form->getValue('name'));
                  $mailView->assign('email', $form->getValue('email'));
                  $mailView->assign('message', $form->getValue('message'));
                  $mailContent = $mailView->render('mailContact.phtml');
                  $mail = new Zend_Mail();
                  $mail->addTo('recipient@domain.com');
                  $mail->setSubject('Web Contact');
                  $mail->setBodyHtml($mailContent, 'UTF-8');
                  $this->_flashMessenger->addMessage('Thank you for your message!');
                  $this->_redirector->setExit(false)->gotoUrl('/about/contact');
                  $mail->send();
                  

                  where $this->_redirector is an instance of *Zend_Controller_Action_Helper_Redirector*

                  This doesn't seem to make a difference, the script is still blocked while the mail is sent after which the redirection occurs.

                  Perhaps I should write a Controller Plugin, would using a postDispatch() hook allow me to send the mail after the visitor has been redirected?

                  Suggestions are welcome!

                  解决方案

                  Why don't you try this:

                  1. Load the view
                  2. Call an Ajax Script from within the view that will load the controller responsible for sending the email.

                  这篇关于发送邮件而不阻止“执行"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Zend_Controller_Router_Exception: quot;xyzquot; is not specified(Zend_Controller_Router_Exception:“xyz;未指定)
                  Zend_Db_Table subquery(Zend_Db_Table 子查询)
                  pcntl_fork and the MySQL connection is gone(pcntl_fork 和 MySQL 连接消失了)
                  Change layout in the controller of Zend Framework 2.0(在 Zend Framework 2.0 的控制器中更改布局)
                  Zend Mail Gmail SMTP(Zend 邮件 Gmail SMTP)
                  Zend_Form: how to check 2 fields are identical(Zend_Form:如何检查 2 个字段是否相同)
                    <tfoot id='DFhy8'></tfoot>

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

                        <legend id='DFhy8'><style id='DFhy8'><dir id='DFhy8'><q id='DFhy8'></q></dir></style></legend>
                      • <small id='DFhy8'></small><noframes id='DFhy8'>

                          <tbody id='DFhy8'></tbody>

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