当前位置: 首页>>代码示例>>PHP>>正文


PHP SMTP::reset方法代码示例

本文整理汇总了PHP中SMTP::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP SMTP::reset方法的具体用法?PHP SMTP::reset怎么用?PHP SMTP::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMTP的用法示例。


在下文中一共展示了SMTP::reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smtpSend

 /**
  * Send mail via SMTP.
  * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
  * Uses the PHPMailerSMTP class by default.
  *
  * @see PHPMailer::getSMTPInstance() to use a different class.
  *
  * @param string $header The message headers
  * @param string $body   The message body
  *
  * @throws phpmailerException
  *
  * @uses SMTP
  *
  * @return bool
  */
 protected function smtpSend($header, $body)
 {
     $bad_rcpt = [];
     if (!$this->smtpConnect()) {
         throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
     }
     $smtp_from = $this->Sender == '' ? $this->From : $this->Sender;
     if (!$this->smtp->mail($smtp_from)) {
         $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
         throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
     }
     // Attempt to send to all recipients
     foreach ($this->to as $to) {
         if (!$this->smtp->recipient($to[0])) {
             $bad_rcpt[] = $to[0];
             $isSent = false;
         } else {
             $isSent = true;
         }
         $this->doCallback($isSent, [$to[0]], [], [], $this->Subject, $body, $this->From);
     }
     foreach ($this->cc as $cc) {
         if (!$this->smtp->recipient($cc[0])) {
             $bad_rcpt[] = $cc[0];
             $isSent = false;
         } else {
             $isSent = true;
         }
         $this->doCallback($isSent, [], [$cc[0]], [], $this->Subject, $body, $this->From);
     }
     foreach ($this->bcc as $bcc) {
         if (!$this->smtp->recipient($bcc[0])) {
             $bad_rcpt[] = $bcc[0];
             $isSent = false;
         } else {
             $isSent = true;
         }
         $this->doCallback($isSent, [], [], [$bcc[0]], $this->Subject, $body, $this->From);
     }
     // Only send the DATA command if we have viable recipients
     if (count($this->all_recipients) > count($bad_rcpt) and !$this->smtp->data($header . $body)) {
         throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
     }
     if ($this->SMTPKeepAlive == true) {
         $this->smtp->reset();
     } else {
         $this->smtp->quit();
         $this->smtp->close();
     }
     if (count($bad_rcpt) > 0) {
         // Create error message for any bad addresses
         throw new phpmailerException($this->lang('recipients_failed') . implode(', ', $bad_rcpt), self::STOP_CONTINUE);
     }
     return true;
 }
开发者ID:ahmedash95,项目名称:Lily,代码行数:71,代码来源:class.phpmailer.php

示例2: smtpSend

 /**
  * Send mail via SMTP.
  * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
  * Uses the PHPMailerSMTP class by default.
  * @see PHPMailer::getSMTPInstance() to use a different class.
  * @param string $header The message headers
  * @param string $body The message body
  * @throws phpmailerException
  * @uses SMTP
  * @access protected
  * @return boolean
  */
 protected function smtpSend($header, $body)
 {
     $bad_rcpt = array();
     if (!$this->smtpConnect($this->SMTPOptions)) {
         throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
     }
     if ('' == $this->Sender) {
         $smtp_from = $this->From;
     } else {
         $smtp_from = $this->Sender;
     }
     if (!$this->smtp->mail($smtp_from)) {
         $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
         throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
     }
     // Attempt to send to all recipients
     foreach (array($this->to, $this->cc, $this->bcc) as $togroup) {
         foreach ($togroup as $to) {
             if (!$this->smtp->recipient($to[0])) {
                 $error = $this->smtp->getError();
                 $bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']);
                 $isSent = false;
             } else {
                 $isSent = true;
             }
             $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From);
         }
     }
     // Only send the DATA command if we have viable recipients
     if (count($this->all_recipients) > count($bad_rcpt) and !$this->smtp->data($header . $body)) {
         throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
     }
     if ($this->SMTPKeepAlive) {
         $this->smtp->reset();
     } else {
         $this->smtp->quit();
         $this->smtp->close();
     }
     //Create error message for any bad addresses
     if (count($bad_rcpt) > 0) {
         $errstr = '';
         foreach ($bad_rcpt as $bad) {
             $errstr .= $bad['to'] . ': ' . $bad['error'];
         }
         throw new phpmailerException($this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE);
     }
     return true;
 }
开发者ID:routenull0,项目名称:phpipam,代码行数:60,代码来源:class.phpmailer.php

示例3: smtpSend

 /**
  * Send mail via SMTP.
  * @return boolean True on success.
  */
 protected function smtpSend()
 {
     $this->smtp = new SMTP();
     $allRecipients = array();
     $badRecipients = array();
     try {
         // <editor-fold desc="Prepare SMTP host.">
         $hostInfo = array();
         if (!preg_match('/^((ssl|tls):\\/\\/)*([a-zA-Z0-9\\.-]*):?([0-9]*)$/', $this->smtpHost, $hostInfo)) {
             throw new \Exception("Invalid SMTP host.");
         }
         $prefix = "";
         $tls = $this->smtpSecure == "tls";
         if ($hostInfo[2] == "ssl" || $hostInfo[2] == "" && $this->smtpSecure == "ssl") {
             $prefix = "ssl://";
             $tls = false;
         } elseif ($hostInfo[2] == "tls") {
             $tls = true;
         }
         $host = $prefix . $hostInfo[3];
         $tport = (int) $hostInfo[4];
         $port = $tport > 0 && $tport < 65536 ? $tport : $this->smtpPort;
         // </editor-fold>
         if (!$this->smtp->connect($host, $port)) {
             throw new \Exception("Could not connect to SMTP host.");
         }
         $hello = !empty($this->smtpHelo) ? $this->smtpHelo : $this->serverHostname();
         if (!$this->smtp->hello($hello)) {
             throw new \Exception("Could not send HELO.");
         }
         if ($tls) {
             if (!$this->smtp->tls()) {
                 throw new \Exception("Could not start TLS.");
             }
             $this->smtp->hello($hello);
         }
         if ($this->smtpAuth && !$this->smtp->authenticate($this->smtpUsername, $this->smtpPassword)) {
             throw new \Exception("Could not authenticate.");
         }
         if (!$this->smtp->mail($this->from[0])) {
             throw new \Exception("Could not send MAIL FROM.");
         }
         foreach ($this->to as $to) {
             if (!$this->smtp->recipient($to[0])) {
                 $badRecipients[] = $to[0];
             } else {
                 $allRecipients[] = $to[0];
             }
         }
         //      foreach ($this->cc as $cc) {
         //        if (!$this->smtp->recipient($cc[0]))
         //          $badRecipients[] = $cc[0];
         //        else
         //          $allRecipients[] = $cc[0];
         //      }
         //
         //      foreach ($this->bcc as $bcc) {
         //        if (!$this->smtp->recipient($bcc[0]))
         //          $badRecipients[] = $bcc[0];
         //        else
         //          $allRecipients[] = $bcc[0];
         //      }
         if (count($allRecipients) > 0 && !$this->smtp->data($this->header . $this->body)) {
             throw new \Exception("Data was not accepted.");
         }
         if ($this->smtpKeepAlive) {
             $this->smtp->reset();
         } else {
             $this->smtp->quit();
             $this->smtp->close();
         }
         return true;
     } catch (\Exception $e) {
         if (count($badRecipients) > 0) {
             $rcpt = implode(", ", $badRecipients);
             throw new EmailException(array("Failed delivery to the following recipient(s): %s.", $rcpt));
         }
         throw new EmailException($e->getMessage());
     }
 }
开发者ID:rolandrajko,项目名称:BREAD,代码行数:84,代码来源:Email.php


注:本文中的SMTP::reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。