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

      <tfoot id='8ADIi'></tfoot>

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

        时间:2023-10-02
      1. <legend id='yjkqR'><style id='yjkqR'><dir id='yjkqR'><q id='yjkqR'></q></dir></style></legend>

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

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

                  <tbody id='yjkqR'></tbody>
                  <bdo id='yjkqR'></bdo><ul id='yjkqR'></ul>

                  本文介绍了使用 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 发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Zend Framework应用层的Master/Slave切换 下一篇:Zend_Mail 发送的电子邮件被视为垃圾邮件

                  相关文章

                  最新文章

                  <small id='3h2PN'></small><noframes id='3h2PN'>

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

                  <legend id='3h2PN'><style id='3h2PN'><dir id='3h2PN'><q id='3h2PN'></q></dir></style></legend>

                      <tfoot id='3h2PN'></tfoot>