<tfoot id='FO19O'></tfoot>
  • <small id='FO19O'></small><noframes id='FO19O'>

    1. <legend id='FO19O'><style id='FO19O'><dir id='FO19O'><q id='FO19O'></q></dir></style></legend>
        • <bdo id='FO19O'></bdo><ul id='FO19O'></ul>

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

        使用 Zend Framework 和 PHP 发送电子邮件

        Sending email using Zend Framework and PHP(使用 Zend Framework 和 PHP 发送电子邮件)
          <tbody id='LRtNf'></tbody>

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

        • <legend id='LRtNf'><style id='LRtNf'><dir id='LRtNf'><q id='LRtNf'></q></dir></style></legend>

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

              • <tfoot id='LRtNf'></tfoot>
                  本文介绍了使用 Zend Framework 和 PHP 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写一个表单,当用户输入他们的电子邮件帐户并点击发送时,一封电子邮件将发送到他们的电子邮件帐户.

                  I working on a form whereby when the user enter in their email account and click on send, an email will be sent to their email account.

                  我已经解决了所有问题.只是它不会将电子邮件发送到我的帐户.有人有想法么?有没有我遗漏的配置之类的?

                  I have everything worked out. Just that it doesnt send the email to my account. Anyone have any ideas? Is there a configuration that I left out or something?

                  这是来自我的控制器的示例:

                  This is the sample from my controller:

                  public function retrieveemailAction(){
                  
                      $users = new Users();
                      $email = $_POST['email'];                
                      $view = Zend_Registry::get('view'); 
                  
                      if($users->checkEmail($_POST['email'])) {
                  
                          // The Subject
                          $subject = "Email Test";
                  
                          // The message
                          $message = "this is a test";            
                  
                          // Send email
                          // Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
                          // Use if command to display email message status
                          if(mail($email, $subject, $message, $headers)) {
                              $view->operation = 'true';
                          }            
                      } else {
                           $view->operation = 'false';
                      }
                  
                      $view->render('retrieve.tpl');
                  }
                  

                  推荐答案

                  我建议您使用 Zend_Mail 而不是 mail().它可以自动处理很多东西,而且效果很好.

                  I recommend you use Zend_Mail instead of mail(). It handles a lot of stuff automatically and just works great.

                  你有 SMTP 服务器吗?尝试在没有您自己的 SMTP 服务器的情况下发送邮件可能会导致邮件无法发送.

                  Do you have a SMTP server? Trying to send mail without your own SMTP server could be causing the mail to not be sent.

                  这是我使用 Zend_Mail 和 Gmail 发送邮件的方式:

                  This is what I use for sending mails using Zend_Mail and Gmail:

                  Bootstrap.php中,我配置了一个默认的邮件传输:

                  In Bootstrap.php, I configure a default mail transport:

                  protected function _initMail()
                  {
                      try {
                          $config = array(
                              'auth' => 'login',
                              'username' => 'username@gmail.com',
                              'password' => 'password',
                              'ssl' => 'tls',
                              'port' => 587
                          );
                  
                          $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
                          Zend_Mail::setDefaultTransport($mailTransport);
                      } catch (Zend_Exception $e){
                          //Do something with exception
                      }
                  }
                  

                  然后我使用以下代码发送电子邮件:

                  Then to send an email I use the following code:

                  //Prepare email
                  $mail = new Zend_Mail();
                  $mail->addTo($email);
                  $mail->setSubject($subject);
                  $mail->setBody($message);
                  $mail->setFrom('username@gmail.com', 'User Name');
                  
                  //Send it!
                  $sent = true;
                  try {
                      $mail->send();
                  } catch (Exception $e){
                      $sent = false;
                  }
                  
                  //Do stuff (display error message, log it, redirect user, etc)
                  if($sent){
                      //Mail was sent successfully.
                  } else {
                      //Mail failed to send.
                  }
                  

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

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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

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

                        <tfoot id='IBSR5'></tfoot>
                            <legend id='IBSR5'><style id='IBSR5'><dir id='IBSR5'><q id='IBSR5'></q></dir></style></legend>