本文整理汇总了PHP中SMTP::Reset方法的典型用法代码示例。如果您正苦于以下问题:PHP SMTP::Reset方法的具体用法?PHP SMTP::Reset怎么用?PHP SMTP::Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMTP
的用法示例。
在下文中一共展示了SMTP::Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Reset
public function Reset()
{
$result = parent::Reset();
$this->handleError();
return $result;
}
示例2: 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;
}