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


PHP SMTP::Quit方法代码示例

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


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

示例1: SMTP

 /**
  * Sends mail via SMTP using PhpSMTP (Author:
  * Chris Ryan).  Returns bool.  Returns false if there is a
  * bad MAIL FROM, RCPT, or DATA input.
  * @private
  * @returns bool
  */
 function smtp_send($header, $body)
 {
     // Include SMTP class code, but not twice
     include_once $this->PluginDir . "class.smtp.php";
     $smtp = new SMTP();
     $smtp->do_debug = $this->SMTPDebug;
     // Try to connect to all SMTP servers
     $hosts = explode(";", $this->Host);
     $index = 0;
     $connection = false;
     $smtp_from = "";
     $bad_rcpt = array();
     $e = "";
     // Retry while there is no connection
     while ($index < count($hosts) && $connection == false) {
         if (strstr($hosts[$index], ":")) {
             list($host, $port) = explode(":", $hosts[$index]);
         } else {
             $host = $hosts[$index];
             $port = $this->Port;
         }
         if ($smtp->Connect($host, $port, $this->Timeout)) {
             $connection = true;
         }
         //printf("%s host could not connect<br>", $hosts[$index]); //debug only
         $index++;
     }
     if (!$connection) {
         $this->error_handler("SMTP Error: could not connect to SMTP host server(s)");
         return false;
     }
     // Must perform HELO before authentication
     $smtp->Hello($this->Helo);
     // If user requests SMTP authentication
     if ($this->SMTPAuth) {
         if (!$smtp->Authenticate($this->Username, $this->Password)) {
             $this->error_handler("SMTP Error: Could not authenticate");
             return false;
         }
     }
     if ($this->Sender == "") {
         $smtp_from = $this->From;
     } else {
         $smtp_from = $this->Sender;
     }
     if (!$smtp->Mail(sprintf("<%s>", $smtp_from))) {
         $e = sprintf("SMTP Error: From address [%s] failed", $smtp_from);
         $this->error_handler($e);
         return false;
     }
     // Attempt to send attach all recipients
     for ($i = 0; $i < count($this->to); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) {
             $bad_rcpt[] = $this->to[$i][0];
         }
     }
     for ($i = 0; $i < count($this->cc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) {
             $bad_rcpt[] = $this->cc[$i][0];
         }
     }
     for ($i = 0; $i < count($this->bcc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) {
             $bad_rcpt[] = $this->bcc[$i][0];
         }
     }
     // Create error message
     if (count($bad_rcpt) > 0) {
         for ($i = 0; $i < count($bad_rcpt); $i++) {
             if ($i != 0) {
                 $e .= ", ";
             }
             $e .= $bad_rcpt[$i];
         }
         $e = sprintf("SMTP Error: The following recipients failed [%s]", $e);
         $this->error_handler($e);
         return false;
     }
     if (!$smtp->Data(sprintf("%s%s", $header, $body))) {
         $this->error_handler("SMTP Error: Data not accepted");
         return false;
     }
     $smtp->Quit();
     return true;
 }
开发者ID:raju99,项目名称:sparkswap,代码行数:92,代码来源:mailerClass.php

示例2: SMTP

 function smtp_send($header, $body)
 {
     include "smtp.inc.php";
     // Load code only if asked
     $smtp = new SMTP();
     $smtp->do_debug = $this->SMTPDebug;
     // Try to connect to all SMTP servers
     $hosts = explode(";", $this->Host);
     $x = 0;
     $connection = false;
     while ($x < count($hosts)) {
         if ($smtp->Connect($hosts[$x], $this->Port, $this->Timeout)) {
             $connection = true;
             break;
         }
         // printf("%s host could not connect<br>", $hosts[$x]); //debug only
         $x++;
     }
     if (!$connection) {
         $this->error_handler("SMTP Error: could not connect to SMTP host server(s)");
     }
     $smtp->Hello($this->Helo);
     $smtp->Mail(sprintf("<%s>", $this->From));
     for ($x = 0; $x < count($this->to); $x++) {
         $smtp->Recipient(sprintf("<%s>", $this->to[$x][0]));
     }
     for ($x = 0; $x < count($this->cc); $x++) {
         $smtp->Recipient(sprintf("<%s>", $this->cc[$x][0]));
     }
     for ($x = 0; $x < count($this->bcc); $x++) {
         $smtp->Recipient(sprintf("<%s>", $this->bcc[$x][0]));
     }
     $smtp->Data(sprintf("%s%s", $header, $body));
     $smtp->Quit();
 }
开发者ID:komunikator,项目名称:komunikator,代码行数:35,代码来源:phpmailer.inc.php

示例3: SMTP

 function smtp_send($header, $body)
 {
     global $enable_debug;
     $smtp = new SMTP();
     $smtp->do_debug = $enable_debug;
     $hosts = explode(";", $this->Host);
     $index = 0;
     $connection = false;
     while ($index < count($hosts) && $connection == false) {
         if ($smtp->Connect($hosts[$index], $this->Port, $this->Timeout)) {
             $connection = true;
         }
         $index++;
     }
     if (!$connection) {
         $this->error_handler("SMTP Error: could not connect to SMTP host server(s)");
         return false;
     }
     if ($this->blUseAuthLogin) {
         if (!$smtp->AuthHello($this->Helo, $this->AuthUser, $this->AuthPass)) {
             $this->error_handler("SMTP Error: Invalid username/password");
             return false;
         }
     } else {
         $smtp->Hello($this->Helo);
     }
     $smtp->MailFrom(sprintf("<%s>", $this->From));
     for ($i = 0; $i < count($this->to); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) {
             $this->error_handler("SMTP Error: Recipient not accepted. Verify your relay rules");
             return false;
         }
     }
     for ($i = 0; $i < count($this->cc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) {
             $this->error_handler("SMTP Error: Recipient not accepted. Verify your relay rules");
             return false;
         }
     }
     for ($i = 0; $i < count($this->bcc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) {
             $this->error_handler("SMTP Error: Recipient not accepted. Verify your relay rules");
             return false;
         }
     }
     if (!$smtp->Data(sprintf("%s%s", $header, $body))) {
         $this->error_handler("SMTP Error: Data not accepted");
         return false;
     }
     $smtp->Quit();
 }
开发者ID:fraancisneiluiz,项目名称:ciaweb,代码行数:51,代码来源:class.smtp.php

示例4: Quit

 public function Quit($close_on_error = true)
 {
     $result = parent::Quit($close_on_error);
     $this->handleError();
     return $result;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:6,代码来源:SMTPProxy.php

示例5: SMTP


//.........这里部分代码省略.........
             $this->Curent_SMTP_Server = $this->Curent_SMTP_Server + 1;
         }
         $index++;
     }
     if (!$connection) {
         //echo "SMTP Error: could not connect to SMTP host server(s) ::: $host";
         $this->error_handler("SMTP Error: could not connect to SMTP host server(s)");
         return false;
     }
     // Must perform HELO before authentication
     $smtp->Hello($this->Helo);
     // If user requests SMTP authentication
     if ($this->SMTPAuth) {
         if (!$smtp->Authenticate($this->Username, $this->Password)) {
             if ($this->Debug_Roll) {
                 echo "<br> SMTP Error: Could not authenticate ({$this->Username}, {$this->Password})";
             }
             $this->error_handler("SMTP Error: Could not authenticate ({$this->Username}, {$this->Password})");
             //echo "<br>SMTP Error: Could not authenticate";
             return false;
         }
     }
     if ($this->Sender == "") {
         $smtp_from = $this->From;
     } else {
         $smtp_from = $this->Sender;
     }
     if (!$smtp->Mail(sprintf("<%s>", $smtp_from))) {
         $e = sprintf("SMTP Error: From address [%s] failed", $smtp_from);
         if ($this->Debug_Roll) {
             echo "<br> {$e}";
         }
         $this->error_handler($e);
         return false;
     }
     // Attempt to send attach all recipients
     for ($i = 0; $i < count($this->to); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) {
             if ($smtp->code_error != 550) {
                 //Relaying denied
                 $bad_rcpt[] = $this->to[$i][0];
             } else {
                 if ($this->Debug_Roll) {
                     echo "<br><br> Relaying denied !!!";
                 }
                 if ($this->Debug_Roll) {
                     echo "<br>  --> Host_USED: {$host} Port_USED: {$port} --->";
                 }
                 if ($this->Debug_Roll) {
                     echo "<br>Curent_SMTP_Server : " . $this->Curent_SMTP_Server;
                 }
                 if ($this->Debug_Roll) {
                     echo "<br> NB TRY : " . $this->nb_try . "<br>";
                 }
                 if ($this->Debug_Roll) {
                     print_r($hosts);
                 }
                 $this->Recup_code_error = $smtp->code_error;
                 return false;
             }
         }
     }
     for ($i = 0; $i < count($this->cc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) {
             $bad_rcpt[] = $this->cc[$i][0];
         }
     }
     for ($i = 0; $i < count($this->bcc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) {
             $bad_rcpt[] = $this->bcc[$i][0];
         }
     }
     // Create error message
     if (count($bad_rcpt) > 0) {
         for ($i = 0; $i < count($bad_rcpt); $i++) {
             if ($i != 0) {
                 $e .= ", ";
             }
             $e .= $bad_rcpt[$i];
         }
         $e = sprintf("SMTP Error: The following recipients failed [%s]", $e);
         $this->error_handler($e);
         if ($this->Debug_Roll) {
             echo "<br>{$e}";
         }
         return false;
     }
     if (!$smtp->Data(sprintf("%s%s", $header, $body))) {
         $this->error_handler("SMTP Error: Data not accepted");
         if ($this->Debug_Roll) {
             echo "<br>SMTP Error: Data not accepted";
         }
         return false;
     }
     $smtp->Quit();
     if ($this->Debug_Roll) {
         echo "<br> SUCCESS !!!";
     }
     return true;
 }
开发者ID:sayemk,项目名称:a2billing,代码行数:101,代码来源:class.phpmailer.php

示例6: send

 public function send($para = array(), $single = false, $priority = 3, $extHeader = "")
 {
     if ($this->from == '') {
         $this->from = ini_get('sendmail_from');
     }
     $this->addHeader("Return-Path", $this->from);
     $mail_list = array_merge($this->to, $this->cc, $this->bcc);
     if ($single == false) {
         if (count($this->to) > 0) {
             $this->addHeader("To", implode(', ', $this->formatEmail($this->to)));
         }
         if (count($this->cc) > 0) {
             $this->addHeader("Cc", implode(', ', $this->formatEmail($this->cc)));
         }
         if (count($this->bcc) > 0) {
             $this->addHeader("Bcc", implode(', ', $this->formatEmail($this->bcc)));
         }
     }
     $this->addHeader("From", $this->from);
     if (count($this->reply) > 0) {
         $this->addHeader("Reply-To", implode(', ', $this->formatEmail($this->reply)));
     }
     $this->addHeader("Subject", $this->subject);
     $this->addHeader("Message-ID", sprintf("<%s@%s>", md5(uniqid(time())), $_SERVER["HTTP_HOST"]));
     if (!preg_match("/[1-5]/", $priority)) {
         $priority = 3;
     }
     $this->addHeader("X-Priority", $priority);
     $this->addHeader("X-Mailer", "MyStep_CMS");
     $this->addHeader("MIME-Version", "1.0");
     $mail_content = implode("\r\n", $this->headers) . "\r\n";
     if (!empty($extHeader)) {
         $mail_content .= $extHeader . "\r\n";
     }
     $mail_content .= $this->buildMail();
     $info = "";
     if (!empty($para['mode'])) {
         require "class.smtp.php";
         $smtp = new SMTP();
         if (!$smtp->Connect(($para['mode'] == "ssl" || $para['mode'] == "ssl/tls" ? "ssl://" : "") . $para['host'], $para['port'], 10)) {
             $this->Error("Cannot connect to the mail server!");
             return false;
         }
         if (!$smtp->Hello($_SERVER["HTTP_HOST"])) {
             $this->Error("Cannot send messege to the mail server!");
             return false;
         }
         if ($para['mode'] == "tls" || $para['mode'] == "ssl/tls") {
             if (!$smtp->StartTLS()) {
                 $this->Error("TLS error!");
                 return false;
             }
             $smtp->Hello($_SERVER["HTTP_HOST"]);
         }
         if (isset($para['user'])) {
             if (!$smtp->Authenticate($para['user'], $para['password'])) {
                 $this->Error("Authenticate Failed!");
                 return false;
             }
         }
         if (!$smtp->Mail(ini_get('sendmail_from'))) {
             $this->Error("Bad sender email");
             return false;
         }
         for ($i = 0, $m = count($mail_list); $i < $m; $i++) {
             if ($smtp->Recipient($mail_list[$i][0])) {
                 $info = " sended!";
             } else {
                 $info = " error!";
             }
             if ($this->log_fp) {
                 fwrite($this->log_fp, $mail_list[$i][0] . $info . "\n");
             }
         }
         if (!$smtp->Data($mail_content)) {
             $this->Error("Mail send Failed!");
             return false;
         }
         $smtp->Reset();
         if ($smtp->Connected()) {
             $smtp->Quit();
             $smtp->Close();
         }
     } else {
         for ($i = 0, $m = count($mail_list); $i < $m; $i++) {
             if (!@mail(formatEmail($mail_list[$i]), $this->subject, "", $mail_content)) {
                 $info = " sended!";
             } else {
                 $info = " error!";
             }
             if ($this->log_fp) {
                 fwrite($this->log_fp, $mail_list[$i][0] . $info . "\n");
             }
         }
     }
     if ($this->log_fp) {
         fclose($this->log_fp);
     }
     return true;
 }
开发者ID:laiello,项目名称:mystep-cms,代码行数:100,代码来源:myemail.class.php

示例7: SMTP

 function _send_mail($msgdata)
 {
     $smtp = new SMTP();
     $smtp->debug = $this->debug;
     if (!$smtp->Connect($this->host, $this->port, $this->timeout)) {
         $this->errormsg = "SMTP Error: could not connect to SMTP host server";
         $this->errormsg .= "[" . $this->host . ":" . $this->port . "]";
         return false;
     }
     if ($this->authlogin) {
         if (!$smtp->AuthHello($this->helo, $this->authuser, $this->authpass)) {
             $this->errormsg = "SMTP Error: Invalid username/password";
             if ($smtp->errormsg) {
                 $this->errormsg .= "<br/>" . $smtp->errormsg;
             }
             return false;
         }
     } else {
         $smtp->Hello($this->helo);
     }
     if (!$smtp->MailFrom(sprintf("<%s>", $this->from))) {
         $this->errormsg = "SMTP Error: Mail from [" . $this->from . "] not accepted.";
         if ($smtp->errormsg) {
             $this->errormsg .= "<br/>" . $smtp->errormsg;
         }
         return false;
     }
     $iToCount = count($this->to);
     for ($i = 0; $i < $iToCount; $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) {
             $this->errormsg = "SMTP Error: Recipient [" . $this->to[$i][0] . "] not accepted.";
             if ($smtp->errormsg) {
                 $this->errormsg .= "<br/>" . $smtp->errormsg;
             }
             return false;
         }
     }
     $iCcCount = count($this->cc);
     for ($i = 0; $i < $iCcCount; $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) {
             $this->errormsg = "SMTP Error: Recipient [" . $this->cc[$i][0] . "] not accepted.";
             if ($smtp->errormsg) {
                 $this->errormsg .= "<br/>" . $smtp->errormsg;
             }
             return false;
         }
     }
     $iBccCount = count($this->bcc);
     for ($i = 0; $i < $iBccCount; $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) {
             $this->errormsg = "SMTP Error: Recipient [" . $this->bcc[$i][0] . "] not accepted.";
             if ($smtp->errormsg) {
                 $this->errormsg .= "<br/>" . $smtp->errormsg;
             }
             return false;
         }
     }
     if (!$smtp->Data($msgdata)) {
         $this->errormsg = "SMTP Error: Data not accepted";
         if ($smtp->errormsg) {
             $this->errormsg .= "<br/>" . $smtp->errormsg;
         }
         return false;
     }
     $smtp->Quit();
 }
开发者ID:honj51,项目名称:taobaocrm,代码行数:66,代码来源:class.smtp.php

示例8: SMTP

 function smtp_send($header, $body)
 {
     $smtp = new SMTP();
     $smtp->do_debug = $this->SMTPDebug;
     $hosts = explode(";", $this->Host);
     $index = 0;
     $connection = false;
     $smtp_from = "";
     $bad_rcpt = array();
     $e = "";
     while ($index < count($hosts) && $connection == false) {
         if (strstr($hosts[$index], ":")) {
             list($host, $port) = explode(":", $hosts[$index]);
         } else {
             $host = $hosts[$index];
             $port = $this->Port;
         }
         if ($smtp->Connect($host, $port, $this->Timeout)) {
             $connection = true;
         }
         $index++;
     }
     if (!$connection) {
         $this->error_handler("SMTP Error: could not connect to SMTP host server(s)");
         return false;
     }
     $smtp->Hello($this->Helo);
     if ($this->SMTPAuth) {
         if (!$smtp->Authenticate($this->Username, $this->Password)) {
             $this->error_handler("SMTP Error: Could not authenticate");
             return false;
         }
     }
     if ($this->Sender == "") {
         $smtp_from = $this->From;
     } else {
         $smtp_from = $this->Sender;
     }
     if (!$smtp->Mail(sprintf("<%s>", $smtp_from))) {
         $e = sprintf("SMTP Error: From address [%s] failed", $smtp_from);
         $this->error_handler($e);
         return false;
     }
     for ($i = 0; $i < count($this->to); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) {
             $bad_rcpt[] = $this->to[$i][0];
         }
     }
     for ($i = 0; $i < count($this->cc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) {
             $bad_rcpt[] = $this->cc[$i][0];
         }
     }
     for ($i = 0; $i < count($this->bcc); $i++) {
         if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) {
             $bad_rcpt[] = $this->bcc[$i][0];
         }
     }
     if (count($bad_rcpt) > 0) {
         for ($i = 0; $i < count($bad_rcpt); $i++) {
             if ($i != 0) {
                 $e .= ", ";
             }
             $e .= $bad_rcpt[$i];
         }
         $e = sprintf("SMTP Error: The following recipients failed [%s]", $e);
         $this->error_handler($e);
         return false;
     }
     if (!$smtp->Data(sprintf("%s%s", $header, $body))) {
         $this->error_handler("SMTP Error: Data not accepted");
         return false;
     }
     $smtp->Quit();
     return true;
 }
开发者ID:nopuls,项目名称:dzcp,代码行数:76,代码来源:sendmail.php


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