Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace PHPMailer\PHPMailer; class PHPMailer { const CHARSET_ASCII = "\165\163\x2..

Decoded Output download

<?php
 namespace PHPMailer\PHPMailer; class PHPMailer { const CHARSET_ASCII = "us-ascii"; const CHARSET_ISO88591 = "iso-8859-1"; const CHARSET_UTF8 = "utf-8"; const CONTENT_TYPE_PLAINTEXT = "text/plain"; const CONTENT_TYPE_TEXT_CALENDAR = "text/calendar"; const CONTENT_TYPE_TEXT_HTML = "text/html"; const CONTENT_TYPE_MULTIPART_ALTERNATIVE = "multipart/alternative"; const CONTENT_TYPE_MULTIPART_MIXED = "multipart/mixed"; const CONTENT_TYPE_MULTIPART_RELATED = "multipart/related"; const ENCODING_7BIT = "7bit"; const ENCODING_8BIT = "8bit"; const ENCODING_BASE64 = "base64"; const ENCODING_BINARY = "binary"; const ENCODING_QUOTED_PRINTABLE = "quoted-printable"; const ENCRYPTION_STARTTLS = "tls"; const ENCRYPTION_SMTPS = "ssl"; const ICAL_METHOD_REQUEST = "REQUEST"; const ICAL_METHOD_PUBLISH = "PUBLISH"; const ICAL_METHOD_REPLY = "REPLY"; const ICAL_METHOD_ADD = "ADD"; const ICAL_METHOD_CANCEL = "CANCEL"; const ICAL_METHOD_REFRESH = "REFRESH"; const ICAL_METHOD_COUNTER = "COUNTER"; const ICAL_METHOD_DECLINECOUNTER = "DECLINECOUNTER"; public $Priority; public $CharSet = self::CHARSET_ISO88591; public $ContentType = self::CONTENT_TYPE_PLAINTEXT; public $Encoding = self::ENCODING_8BIT; public $ErrorInfo = ''; public $From = ''; public $FromName = ''; public $Sender = ''; public $Subject = ''; public $Body = ''; public $AltBody = ''; public $Ical = ''; protected static $IcalMethods = array(self::ICAL_METHOD_REQUEST, self::ICAL_METHOD_PUBLISH, self::ICAL_METHOD_REPLY, self::ICAL_METHOD_ADD, self::ICAL_METHOD_CANCEL, self::ICAL_METHOD_REFRESH, self::ICAL_METHOD_COUNTER, self::ICAL_METHOD_DECLINECOUNTER); protected $MIMEBody = ''; protected $MIMEHeader = ''; protected $mailHeader = ''; public $WordWrap = 0; public $Mailer = "mail"; public $Sendmail = "/usr/sbin/sendmail"; public $UseSendmailOptions = true; public $ConfirmReadingTo = ''; public $Hostname = ''; public $MessageID = ''; public $MessageDate = ''; public $Host = "localhost"; public $Port = 25; public $Helo = ''; public $SMTPSecure = ''; public $SMTPAutoTLS = true; public $SMTPAuth = false; public $SMTPOptions = array(); public $Username = ''; public $Password = ''; public $AuthType = ''; protected $SMTPXClient = array(); protected $oauth; public $Timeout = 300; public $dsn = ''; public $SMTPDebug = 0; public $Debugoutput = "echo"; public $SMTPKeepAlive = false; public $SingleTo = false; protected $SingleToArray = array(); public $do_verp = false; public $AllowEmpty = false; public $DKIM_selector = ''; public $DKIM_identity = ''; public $DKIM_passphrase = ''; public $DKIM_domain = ''; public $DKIM_copyHeaderFields = true; public $DKIM_extraHeaders = array(); public $DKIM_private = ''; public $DKIM_private_string = ''; public $action_function = ''; public $XMailer = ''; public static $validator = "php"; protected $smtp; protected $to = array(); protected $cc = array(); protected $bcc = array(); protected $ReplyTo = array(); protected $all_recipients = array(); protected $RecipientsQueue = array(); protected $ReplyToQueue = array(); protected $attachment = array(); protected $CustomHeader = array(); protected $lastMessageID = ''; protected $message_type = ''; protected $boundary = array(); protected $language = array(); protected $error_count = 0; protected $sign_cert_file = ''; protected $sign_key_file = ''; protected $sign_extracerts_file = ''; protected $sign_key_pass = ''; protected $exceptions = false; protected $uniqueid = ''; const VERSION = "6.9.1"; const STOP_MESSAGE = 0; const STOP_CONTINUE = 1; const STOP_CRITICAL = 2; const CRLF = "
"; const FWS = " "; protected static $LE = self::CRLF; const MAIL_MAX_LINE_LENGTH = 63; const MAX_LINE_LENGTH = 998; const STD_LINE_LENGTH = 76; public function __construct($exceptions = null) { if (null !== $exceptions) { $this->exceptions = (bool) $exceptions; } $this->Debugoutput = strpos(PHP_SAPI, "cli") !== false ? "echo" : "html"; } public function __destruct() { $this->smtpClose(); } private function mailPassthru($to, $subject, $body, $header, $params) { if ((int) ini_get("mbstring.func_overload") & 1) { $subject = $this->secureHeader($subject); } else { $subject = $this->encodeHeader($this->secureHeader($subject)); } $this->edebug("Sending with mail()"); $this->edebug("Sendmail path: " . ini_get("sendmail_path")); $this->edebug("Envelope sender: {$this->Sender}"); $this->edebug("To: {$to}"); $this->edebug("Subject: {$subject}"); $this->edebug("Headers: {$header}"); if (!$this->UseSendmailOptions || null === $params) { $result = @mail($to, $subject, $body, $header); } else { $this->edebug("Additional params: {$params}"); $result = @mail($to, $subject, $body, $header, $params); } $this->edebug("Result: " . ($result ? "true" : "false")); return $result; } protected function edebug($str) { if ($this->SMTPDebug <= 0) { return; } if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) { $this->Debugoutput->debug($str); return; } if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, array("error_log", "html", "echo"))) { call_user_func($this->Debugoutput, $str, $this->SMTPDebug); return; } switch ($this->Debugoutput) { case "error_log": error_log($str); break; case "html": echo htmlentities(preg_replace("/[\r\n]+/", '', $str), ENT_QUOTES, "UTF-8"), "<br>
"; break; case "echo": default: $str = preg_replace("/\r\n|\r/m", "
", $str); echo gmdate("Y-m-d H:i:s"), "	", trim(str_replace("
", "
                   \x9                  ", trim($str))), "\xa"; } } public function isHTML($isHtml = true) { if ($isHtml) { $this->ContentType = static::CONTENT_TYPE_TEXT_HTML; } else { $this->ContentType = static::CONTENT_TYPE_PLAINTEXT; } } public function isSMTP() { $this->Mailer = "smtp"; } public function isMail() { $this->Mailer = "mail"; } public function isSendmail() { $ini_sendmail_path = ini_get("sendmail_path"); if (false === stripos($ini_sendmail_path, "sendmail")) { $this->Sendmail = "/usr/sbin/sendmail"; } else { $this->Sendmail = $ini_sendmail_path; } $this->Mailer = "sendmail"; } public function isQmail() { $ini_sendmail_path = ini_get("sendmail_path"); if (false === stripos($ini_sendmail_path, "qmail")) { $this->Sendmail = "/var/qmail/bin/qmail-inject"; } else { $this->Sendmail = $ini_sendmail_path; } $this->Mailer = "qmail"; } public function addAddress($address, $name = '') { return $this->addOrEnqueueAnAddress("to", $address, $name); } public function addCC($address, $name = '') { return $this->addOrEnqueueAnAddress("cc", $address, $name); } public function addBCC($address, $name = '') { return $this->addOrEnqueueAnAddress("bcc", $address, $name); } public function addReplyTo($address, $name = '') { return $this->addOrEnqueueAnAddress("Reply-To", $address, $name); } protected function addOrEnqueueAnAddress($kind, $address, $name) { $pos = false; if ($address !== null) { $address = trim($address); $pos = strrpos($address, "@"); } if (false === $pos) { $error_message = sprintf("%s (%s): %s", $this->lang("invalid_address"), $kind, $address); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } if ($name !== null && is_string($name)) { $name = trim(preg_replace("/[\r\n]+/", '', $name)); } else { $name = ''; } $params = array($kind, $address, $name); if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) { if ("Reply-To" !== $kind) { if (!array_key_exists($address, $this->RecipientsQueue)) { $this->RecipientsQueue[$address] = $params; return true; } } elseif (!array_key_exists($address, $this->ReplyToQueue)) { $this->ReplyToQueue[$address] = $params; return true; } return false; } return call_user_func_array(array($this, "addAnAddress"), $params); } public function setBoundaries() { $this->uniqueid = $this->generateId(); $this->boundary[1] = "b1=_" . $this->uniqueid; $this->boundary[2] = "b2=_" . $this->uniqueid; $this->boundary[3] = "b3=_" . $this->uniqueid; } protected function addAnAddress($kind, $address, $name = '') { if (!in_array($kind, array("to", "cc", "bcc", "Reply-To"))) { $error_message = sprintf("%s: %s", $this->lang("Invalid recipient kind"), $kind); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } if (!static::validateAddress($address)) { $error_message = sprintf("%s (%s): %s", $this->lang("invalid_address"), $kind, $address); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } if ("Reply-To" !== $kind) { if (!array_key_exists(strtolower($address), $this->all_recipients)) { $this->{$kind}[] = array($address, $name); $this->all_recipients[strtolower($address)] = true; return true; } } elseif (!array_key_exists(strtolower($address), $this->ReplyTo)) { $this->ReplyTo[strtolower($address)] = array($address, $name); return true; } return false; } public static function parseAddresses($addrstr, $useimap = true, $charset = self::CHARSET_ISO88591) { $addresses = array(); if ($useimap && function_exists("imap_rfc822_parse_adrlist")) { $list = imap_rfc822_parse_adrlist($addrstr, ''); imap_errors(); foreach ($list as $address) { if (".SYNTAX-ERROR." !== $address->host && static::validateAddress($address->mailbox . "@" . $address->host)) { if (property_exists($address, "personal") && defined("MB_CASE_UPPER") && preg_match("/^=\?.*\?=$/s", $address->personal)) { $origCharset = mb_internal_encoding(); mb_internal_encoding($charset); $address->personal = str_replace("_", "=20", $address->personal); $address->personal = mb_decode_mimeheader($address->personal); mb_internal_encoding($origCharset); } $addresses[] = array("name" => property_exists($address, "personal") ? $address->personal : '', "address" => $address->mailbox . "@" . $address->host); } } } else { $list = explode(",", $addrstr); foreach ($list as $address) { $address = trim($address); if (strpos($address, "<") === false) { if (static::validateAddress($address)) { $addresses[] = array("name" => '', "address" => $address); } } else { list($name, $email) = explode("<", $address); $email = trim(str_replace(">", '', $email)); $name = trim($name); if (static::validateAddress($email)) { if (defined("MB_CASE_UPPER") && preg_match("/^=\?.*\?=$/s", $name)) { $origCharset = mb_internal_encoding(); mb_internal_encoding($charset); $name = str_replace("_", "=20", $name); $name = mb_decode_mimeheader($name); mb_internal_encoding($origCharset); } $addresses[] = array("name" => trim($name, "'" "), "address" => $email); } } } } return $addresses; } public function setFrom($address, $name = '', $auto = true) { $address = trim((string) $address); $name = trim(preg_replace("/[\r\n]+/", '', $name)); $pos = strrpos($address, "@"); if (false === $pos || (!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) && !static::validateAddress($address)) { $error_message = sprintf("%s (From): %s", $this->lang("invalid_address"), $address); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } $this->From = $address; $this->FromName = $name; if ($auto && empty($this->Sender)) { $this->Sender = $address; } return true; } public function getLastMessageID() { return $this->lastMessageID; } public static function validateAddress($address, $patternselect = null) { if (null === $patternselect) { $patternselect = static::$validator; } if (is_callable($patternselect) && !is_string($patternselect)) { return call_user_func($patternselect, $address); } if (strpos($address, "
") !== false || strpos($address, "
") !== false) { return false; } switch ($patternselect) { case "pcre": case "pcre8": return (bool) preg_match("/^(?!(?>(?1)"?(?>\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\[ -~]|[^"])"?(?1)){65,}@)" . "((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)" . "(?>[\x01-\x08\x0B\x0C\x0E-'*-\[\]-\x7F]|\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)" . "([!#-'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\[\x00-\x7F]))*" . "(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)" . "(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}" . "|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:" . "|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}" . "|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD", $address); case "html5": return (bool) preg_match("/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}" . "[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD", $address); case "php": default: return filter_var($address, FILTER_VALIDATE_EMAIL) !== false; } } public static function idnSupported() { return function_exists("idn_to_ascii") && function_exists("mb_convert_encoding"); } public function punyencodeAddress($address) { $pos = strrpos($address, "@"); if (!empty($this->CharSet) && false !== $pos && static::idnSupported()) { $domain = substr($address, ++$pos); if ($this->has8bitChars($domain) && @mb_check_encoding($domain, $this->CharSet)) { $domain = mb_convert_encoding($domain, self::CHARSET_UTF8, $this->CharSet); $errorcode = 0; if (defined("INTL_IDNA_VARIANT_UTS46")) { $punycode = idn_to_ascii($domain, \IDNA_DEFAULT | \IDNA_USE_STD3_RULES | \IDNA_CHECK_BIDI | \IDNA_CHECK_CONTEXTJ | \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46); } elseif (defined("INTL_IDNA_VARIANT_2003")) { $punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_2003); } else { $punycode = idn_to_ascii($domain, $errorcode); } if (false !== $punycode) { return substr($address, 0, $pos) . $punycode; } } } return $address; } public function send() { try { if (!$this->preSend()) { return false; } return $this->postSend(); } catch (Exception $exc) { $this->mailHeader = ''; $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } } public function preSend() { if ("smtp" === $this->Mailer || "mail" === $this->Mailer && (\PHP_VERSION_ID >= 80000 || stripos(PHP_OS, "WIN") === 0)) { static::setLE(self::CRLF); } else { static::setLE(PHP_EOL); } if ("mail" === $this->Mailer && (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70017 || \PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70103) && ini_get("mail.add_x_header") === "1" && stripos(PHP_OS, "WIN") === 0) { trigger_error($this->lang("buggy_php"), E_USER_WARNING); } try { $this->error_count = 0; $this->mailHeader = ''; foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { $params[1] = $this->punyencodeAddress($params[1]); call_user_func_array(array($this, "addAnAddress"), $params); } if (count($this->to) + count($this->cc) + count($this->bcc) < 1) { throw new Exception($this->lang("provide_address"), self::STOP_CRITICAL); } foreach (array("From", "Sender", "ConfirmReadingTo") as $address_kind) { if ($this->{$address_kind} === null) { $this->{$address_kind} = ''; continue; } $this->{$address_kind} = trim($this->{$address_kind}); if (empty($this->{$address_kind})) { continue; } $this->{$address_kind} = $this->punyencodeAddress($this->{$address_kind}); if (!static::validateAddress($this->{$address_kind})) { $error_message = sprintf("%s (%s): %s", $this->lang("invalid_address"), $address_kind, $this->{$address_kind}); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } } if ($this->alternativeExists()) { $this->ContentType = static::CONTENT_TYPE_MULTIPART_ALTERNATIVE; } $this->setMessageType(); if (!$this->AllowEmpty && empty($this->Body)) { throw new Exception($this->lang("empty_message"), self::STOP_CRITICAL); } $this->Subject = trim($this->Subject); $this->MIMEHeader = ''; $this->MIMEBody = $this->createBody(); $tempheaders = $this->MIMEHeader; $this->MIMEHeader = $this->createHeader(); $this->MIMEHeader .= $tempheaders; if ("mail" === $this->Mailer) { if (count($this->to) > 0) { $this->mailHeader .= $this->addrAppend("To", $this->to); } else { $this->mailHeader .= $this->headerLine("To", "undisclosed-recipients:;"); } $this->mailHeader .= $this->headerLine("Subject", $this->encodeHeader($this->secureHeader($this->Subject))); } if (!empty($this->DKIM_domain) && !empty($this->DKIM_selector) && (!empty($this->DKIM_private_string) || !empty($this->DKIM_private) && static::isPermittedPath($this->DKIM_private) && file_exists($this->DKIM_private))) { $header_dkim = $this->DKIM_Add($this->MIMEHeader . $this->mailHeader, $this->encodeHeader($this->secureHeader($this->Subject)), $this->MIMEBody); $this->MIMEHeader = static::stripTrailingWSP($this->MIMEHeader) . static::$LE . static::normalizeBreaks($header_dkim) . static::$LE; } return true; } catch (Exception $exc) { $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } } public function postSend() { try { switch ($this->Mailer) { case "sendmail": case "qmail": return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); case "smtp": return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); case "mail": return $this->mailSend($this->MIMEHeader, $this->MIMEBody); default: $sendMethod = $this->Mailer . "Send"; if (method_exists($this, $sendMethod)) { return $this->{$sendMethod}($this->MIMEHeader, $this->MIMEBody); } return $this->mailSend($this->MIMEHeader, $this->MIMEBody); } } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->Mailer === "smtp" && $this->SMTPKeepAlive == true && $this->smtp->connected()) { $this->smtp->reset(); } if ($this->exceptions) { throw $exc; } } return false; } protected function sendmailSend($header, $body) { if ($this->Mailer === "qmail") { $this->edebug("Sending with qmail"); } else { $this->edebug("Sending with sendmail"); } $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; $sendmail_from_value = ini_get("sendmail_from"); if (empty($this->Sender) && !empty($sendmail_from_value)) { $this->Sender = ini_get("sendmail_from"); } if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) { if ($this->Mailer === "qmail") { $sendmailFmt = "%s -f%s"; } else { $sendmailFmt = "%s -oi -f%s -t"; } } else { $sendmailFmt = "%s -oi -t"; } $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); $this->edebug("Sendmail path: " . $this->Sendmail); $this->edebug("Sendmail command: " . $sendmail); $this->edebug("Envelope sender: " . $this->Sender); $this->edebug("Headers: {$header}"); if ($this->SingleTo) { foreach ($this->SingleToArray as $toAddr) { $mail = @popen($sendmail, "w"); if (!$mail) { throw new Exception($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } $this->edebug("To: {$toAddr}"); fwrite($mail, "To: " . $toAddr . "\xa"); fwrite($mail, $header); fwrite($mail, $body); $result = pclose($mail); $addrinfo = static::parseAddresses($toAddr, true, $this->CharSet); $this->doCallback($result === 0, array(array($addrinfo["address"], $addrinfo["name"])), $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); $this->edebug("Result: " . ($result === 0 ? "true" : "false")); if (0 !== $result) { throw new Exception($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } } } else { $mail = @popen($sendmail, "w"); if (!$mail) { throw new Exception($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } fwrite($mail, $header); fwrite($mail, $body); $result = pclose($mail); $this->doCallback($result === 0, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); $this->edebug("Result: " . ($result === 0 ? "true" : "false")); if (0 !== $result) { throw new Exception($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } } return true; } protected static function isShellSafe($string) { if (!function_exists("escapeshellarg") || !function_exists("escapeshellcmd")) { return false; } if (escapeshellcmd($string) !== $string || !in_array(escapeshellarg($string), array("'{$string}'", ""{$string}""))) { return false; } $length = strlen($string); for ($i = 0; $i < $length; ++$i) { $c = $string[$i]; if (!ctype_alnum($c) && strpos("@_-.", $c) === false) { return false; } } return true; } protected static function isPermittedPath($path) { return !preg_match("#^[a-z][a-z\d+.-]*://#i", $path); } protected static function fileIsAccessible($path) { if (!static::isPermittedPath($path)) { return false; } $readable = is_file($path); if (strpos($path, "\\") !== 0) { $readable = $readable && is_readable($path); } return $readable; } protected function mailSend($header, $body) { $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; $toArr = array(); foreach ($this->to as $toaddr) { $toArr[] = $this->addrFormat($toaddr); } $to = trim(implode(", ", $toArr)); if ($to === '') { $to = "undisclosed-recipients:;"; } $params = null; $sendmail_from_value = ini_get("sendmail_from"); if (empty($this->Sender) && !empty($sendmail_from_value)) { $this->Sender = ini_get("sendmail_from"); } if (!empty($this->Sender) && static::validateAddress($this->Sender)) { if (self::isShellSafe($this->Sender)) { $params = sprintf("-f%s", $this->Sender); } $old_from = ini_get("sendmail_from"); ini_set("sendmail_from", $this->Sender); } $result = false; if ($this->SingleTo && count($toArr) > 1) { foreach ($toArr as $toAddr) { $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); $addrinfo = static::parseAddresses($toAddr, true, $this->CharSet); $this->doCallback($result, array(array($addrinfo["address"], $addrinfo["name"])), $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); } } else { $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); } if (isset($old_from)) { ini_set("sendmail_from", $old_from); } if (!$result) { throw new Exception($this->lang("instantiate"), self::STOP_CRITICAL); } return true; } public function getSMTPInstance() { if (!is_object($this->smtp)) { $this->smtp = new SMTP(); } return $this->smtp; } public function setSMTPInstance(SMTP $smtp) { $this->smtp = $smtp; return $this->smtp; } public function setSMTPXclientAttribute($name, $value) { if (!in_array($name, SMTP::$xclient_allowed_attributes)) { return false; } if (isset($this->SMTPXClient[$name]) && $value === null) { unset($this->SMTPXClient[$name]); } elseif ($value !== null) { $this->SMTPXClient[$name] = $value; } return true; } public function getSMTPXclientAttributes() { return $this->SMTPXClient; } protected function smtpSend($header, $body) { $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; $bad_rcpt = array(); if (!$this->smtpConnect($this->SMTPOptions)) { throw new Exception($this->lang("smtp_connect_failed"), self::STOP_CRITICAL); } if ('' === $this->Sender) { $smtp_from = $this->From; } else { $smtp_from = $this->Sender; } if (count($this->SMTPXClient)) { $this->smtp->xclient($this->SMTPXClient); } if (!$this->smtp->mail($smtp_from)) { $this->setError($this->lang("from_failed") . $smtp_from . " : " . implode(",", $this->smtp->getError())); throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); } $callbacks = array(); foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { foreach ($togroup as $to) { if (!$this->smtp->recipient($to[0], $this->dsn)) { $error = $this->smtp->getError(); $bad_rcpt[] = array("to" => $to[0], "error" => $error["detail"]); $isSent = false; } else { $isSent = true; } $callbacks[] = array("issent" => $isSent, "to" => $to[0], "name" => $to[1]); } } if (count($this->all_recipients) > count($bad_rcpt) && !$this->smtp->data($header . $body)) { throw new Exception($this->lang("data_not_accepted"), self::STOP_CRITICAL); } $smtp_transaction_id = $this->smtp->getLastTransactionID(); if ($this->SMTPKeepAlive) { $this->smtp->reset(); } else { $this->smtp->quit(); $this->smtp->close(); } foreach ($callbacks as $cb) { $this->doCallback($cb["issent"], array(array($cb["to"], $cb["name"])), array(), array(), $this->Subject, $body, $this->From, array("smtp_transaction_id" => $smtp_transaction_id)); } if (count($bad_rcpt) > 0) { $errstr = ''; foreach ($bad_rcpt as $bad) { $errstr .= $bad["to"] . ": " . $bad["error"]; } throw new Exception($this->lang("recipients_failed") . $errstr, self::STOP_CONTINUE); } return true; } public function smtpConnect($options = null) { if (null === $this->smtp) { $this->smtp = $this->getSMTPInstance(); } if (null === $options) { $options = $this->SMTPOptions; } if ($this->smtp->connected()) { return true; } $this->smtp->setTimeout($this->Timeout); $this->smtp->setDebugLevel($this->SMTPDebug); $this->smtp->setDebugOutput($this->Debugoutput); $this->smtp->setVerp($this->do_verp); if ($this->Host === null) { $this->Host = "localhost"; } $hosts = explode(";", $this->Host); $lastexception = null; foreach ($hosts as $hostentry) { $hostinfo = array(); if (!preg_match("/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/", trim($hostentry), $hostinfo)) { $this->edebug($this->lang("invalid_hostentry") . " " . trim($hostentry)); continue; } if (!static::isValidHost($hostinfo[2])) { $this->edebug($this->lang("invalid_host") . " " . $hostinfo[2]); continue; } $prefix = ''; $secure = $this->SMTPSecure; $tls = static::ENCRYPTION_STARTTLS === $this->SMTPSecure; if ("ssl" === $hostinfo[1] || '' === $hostinfo[1] && static::ENCRYPTION_SMTPS === $this->SMTPSecure) { $prefix = "ssl://"; $tls = false; $secure = static::ENCRYPTION_SMTPS; } elseif ("tls" === $hostinfo[1]) { $tls = true; $secure = static::ENCRYPTION_STARTTLS; } $sslext = defined("OPENSSL_ALGO_SHA256"); if (static::ENCRYPTION_STARTTLS === $secure || static::ENCRYPTION_SMTPS === $secure) { if (!$sslext) { throw new Exception($this->lang("extension_missing") . "openssl", self::STOP_CRITICAL); } } $host = $hostinfo[2]; $port = $this->Port; if (array_key_exists(3, $hostinfo) && is_numeric($hostinfo[3]) && $hostinfo[3] > 0 && $hostinfo[3] < 65536) { $port = (int) $hostinfo[3]; } if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { try { if ($this->Helo) { $hello = $this->Helo; } else { $hello = $this->serverHostname(); } $this->smtp->hello($hello); if ($this->SMTPAutoTLS && $this->Host !== "localhost" && $sslext && $secure !== "ssl" && $this->smtp->getServerExt("STARTTLS")) { $tls = true; } if ($tls) { if (!$this->smtp->startTLS()) { $message = $this->getSmtpErrorMessage("connect_host"); throw new Exception($message); } $this->smtp->hello($hello); } if ($this->SMTPAuth && !$this->smtp->authenticate($this->Username, $this->Password, $this->AuthType, $this->oauth)) { throw new Exception($this->lang("authenticate")); } return true; } catch (Exception $exc) { $lastexception = $exc; $this->edebug($exc->getMessage()); $this->smtp->quit(); } } } $this->smtp->close(); if ($this->exceptions && null !== $lastexception) { throw $lastexception; } if ($this->exceptions) { $message = $this->getSmtpErrorMessage("connect_host"); throw new Exception($message); } return false; } public function smtpClose() { if (null !== $this->smtp && $this->smtp->connected()) { $this->smtp->quit(); $this->smtp->close(); } } public function setLanguage($langcode = "en", $lang_path = '') { $renamed_langcodes = array("br" => "pt_br", "cz" => "cs", "dk" => "da", "no" => "nb", "se" => "sv", "rs" => "sr", "tg" => "tl", "am" => "hy"); if (array_key_exists($langcode, $renamed_langcodes)) { $langcode = $renamed_langcodes[$langcode]; } $PHPMAILER_LANG = array("authenticate" => "SMTP Error: Could not authenticate.", "buggy_php" => "Your version of PHP is affected by a bug that may result in corrupted messages." . " To fix it, switch to sending using SMTP, disable the mail.add_x_header option in" . " your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.", "connect_host" => "SMTP Error: Could not connect to SMTP host.", "data_not_accepted" => "SMTP Error: data not accepted.", "empty_message" => "Message body empty", "encoding" => "Unknown encoding: ", "execute" => "Could not execute: ", "extension_missing" => "Extension missing: ", "file_access" => "Could not access file: ", "file_open" => "File Error: Could not open file: ", "from_failed" => "The following From address failed: ", "instantiate" => "Could not instantiate mail function.", "invalid_address" => "Invalid address: ", "invalid_header" => "Invalid header name or value", "invalid_hostentry" => "Invalid hostentry: ", "invalid_host" => "Invalid host: ", "mailer_not_supported" => " mailer is not supported.", "provide_address" => "You must provide at least one recipient email address.", "recipients_failed" => "SMTP Error: The following recipients failed: ", "signing" => "Signing Error: ", "smtp_code" => "SMTP code: ", "smtp_code_ex" => "Additional SMTP info: ", "smtp_connect_failed" => "SMTP connect() failed.", "smtp_detail" => "Detail: ", "smtp_error" => "SMTP server error: ", "variable_set" => "Cannot set or reset variable: "); if (empty($lang_path)) { $lang_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . "language" . DIRECTORY_SEPARATOR; } $foundlang = true; $langcode = strtolower($langcode); if (!preg_match("/^(?P<lang>[a-z]{2})(?P<script>_[a-z]{4})?(?P<country>_[a-z]{2})?$/", $langcode, $matches) && $langcode !== "en") { $foundlang = false; $langcode = "en"; } if ("en" !== $langcode) { $langcodes = array(); if (!empty($matches["script"]) && !empty($matches["country"])) { $langcodes[] = $matches["lang"] . $matches["script"] . $matches["country"]; } if (!empty($matches["country"])) { $langcodes[] = $matches["lang"] . $matches["country"]; } if (!empty($matches["script"])) { $langcodes[] = $matches["lang"] . $matches["script"]; } $langcodes[] = $matches["lang"]; $foundFile = false; foreach ($langcodes as $code) { $lang_file = $lang_path . "phpmailer.lang-" . $code . ".php"; if (static::fileIsAccessible($lang_file)) { $foundFile = true; break; } } if ($foundFile === false) { $foundlang = false; } else { $lines = file($lang_file); foreach ($lines as $line) { $matches = array(); if (preg_match("/^\$PHPMAILER_LANG\['([a-z\d_]+)'\]\s*=\s*(["'])(.+)*?\2;/", $line, $matches) && array_key_exists($matches[1], $PHPMAILER_LANG)) { $PHPMAILER_LANG[$matches[1]] = (string) $matches[3]; } } } } $this->language = $PHPMAILER_LANG; return $foundlang; } public function getTranslations() { if (empty($this->language)) { $this->setLanguage(); } return $this->language; } public function addrAppend($type, $addr) { $addresses = array(); foreach ($addr as $address) { $addresses[] = $this->addrFormat($address); } return $type . ": " . implode(", ", $addresses) . static::$LE; } public function addrFormat($addr) { if (!isset($addr[1]) || $addr[1] === '') { return $this->secureHeader($addr[0]); } return $this->encodeHeader($this->secureHeader($addr[1]), "phrase") . " <" . $this->secureHeader($addr[0]) . ">"; } public function wrapText($message, $length, $qp_mode = false) { if ($qp_mode) { $soft_break = sprintf(" =%s", static::$LE); } else { $soft_break = static::$LE; } $is_utf8 = static::CHARSET_UTF8 === strtolower($this->CharSet); $lelen = strlen(static::$LE); $crlflen = strlen(static::$LE); $message = static::normalizeBreaks($message); if (substr($message, -$lelen) === static::$LE) { $message = substr($message, 0, -$lelen); } $lines = explode(static::$LE, $message); $message = ''; foreach ($lines as $line) { $words = explode(" ", $line); $buf = ''; $firstword = true; foreach ($words as $word) { if ($qp_mode && strlen($word) > $length) { $space_left = $length - strlen($buf) - $crlflen; if (!$firstword) { if ($space_left > 20) { $len = $space_left; if ($is_utf8) { $len = $this->utf8CharBoundary($word, $len); } elseif ("=" === substr($word, $len - 1, 1)) { --$len; } elseif ("=" === substr($word, $len - 2, 1)) { $len -= 2; } $part = substr($word, 0, $len); $word = substr($word, $len); $buf .= " " . $part; $message .= $buf . sprintf("=%s", static::$LE); } else { $message .= $buf . $soft_break; } $buf = ''; } while ($word !== '') { if ($length <= 0) { break; } $len = $length; if ($is_utf8) { $len = $this->utf8CharBoundary($word, $len); } elseif ("=" === substr($word, $len - 1, 1)) { --$len; } elseif ("=" === substr($word, $len - 2, 1)) { $len -= 2; } $part = substr($word, 0, $len); $word = (string) substr($word, $len); if ($word !== '') { $message .= $part . sprintf("=%s", static::$LE); } else { $buf = $part; } } } else { $buf_o = $buf; if (!$firstword) { $buf .= " "; } $buf .= $word; if ('' !== $buf_o && strlen($buf) > $length) { $message .= $buf_o . $soft_break; $buf = $word; } } $firstword = false; } $message .= $buf . static::$LE; } return $message; } public function utf8CharBoundary($encodedText, $maxLength) { $foundSplitPos = false; $lookBack = 3; while (!$foundSplitPos) { $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); $encodedCharPos = strpos($lastChunk, "="); if (false !== $encodedCharPos) { $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); $dec = hexdec($hex); if ($dec < 128) { if ($encodedCharPos > 0) { $maxLength -= $lookBack - $encodedCharPos; } $foundSplitPos = true; } elseif ($dec >= 192) { $maxLength -= $lookBack - $encodedCharPos; $foundSplitPos = true; } elseif ($dec < 192) { $lookBack += 3; } } else { $foundSplitPos = true; } } return $maxLength; } public function setWordWrap() { if ($this->WordWrap < 1) { return; } switch ($this->message_type) { case "alt": case "alt_inline": case "alt_attach": case "alt_inline_attach": $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap); break; default: $this->Body = $this->wrapText($this->Body, $this->WordWrap); break; } } public function createHeader() { $result = ''; $result .= $this->headerLine("Date", '' === $this->MessageDate ? self::rfcDate() : $this->MessageDate); if ("mail" !== $this->Mailer) { if ($this->SingleTo) { foreach ($this->to as $toaddr) { $this->SingleToArray[] = $this->addrFormat($toaddr); } } elseif (count($this->to) > 0) { $result .= $this->addrAppend("To", $this->to); } elseif (count($this->cc) === 0) { $result .= $this->headerLine("To", "undisclosed-recipients:;"); } } $result .= $this->addrAppend("From", array(array(trim($this->From), $this->FromName))); if (count($this->cc) > 0) { $result .= $this->addrAppend("Cc", $this->cc); } if (("sendmail" === $this->Mailer || "qmail" === $this->Mailer || "mail" === $this->Mailer) && count($this->bcc) > 0) { $result .= $this->addrAppend("Bcc", $this->bcc); } if (count($this->ReplyTo) > 0) { $result .= $this->addrAppend("Reply-To", $this->ReplyTo); } if ("mail" !== $this->Mailer) { $result .= $this->headerLine("Subject", $this->encodeHeader($this->secureHeader($this->Subject))); } if ('' !== $this->MessageID && preg_match("/^<((([a-z\d!#$%&'*+\/=?^_`{|}~-]+(\.[a-z\d!#$%&'*+\/=?^_`{|}~-]+)*)" . "|("(([\x01-\x08\x0B\x0C\x0E-\x1F\x7F]|[\x21\x23-\x5B\x5D-\x7E])" . "|(\[\x01-\x09\x0B\x0C\x0E-\x7F]))*"))@(([a-z\d!#$%&'*+\/=?^_`{|}~-]+" . "(\.[a-z\d!#$%&'*+\/=?^_`{|}~-]+)*)|(\[(([\x01-\x08\x0B\x0C\x0E-\x1F\x7F]" . "|[\x21-\x5A\x5E-\x7E])|(\[\x01-\x09\x0B\x0C\x0E-\x7F]))*\])))>$/Di", $this->MessageID)) { $this->lastMessageID = $this->MessageID; } else { $this->lastMessageID = sprintf("<%s@%s>", $this->uniqueid, $this->serverHostname()); } $result .= $this->headerLine("Message-ID", $this->lastMessageID); if (null !== $this->Priority) { $result .= $this->headerLine("X-Priority", $this->Priority); } if ('' === $this->XMailer) { $result .= $this->headerLine("X-Mailer", "PHPMailer " . self::VERSION . " (https://github.com/PHPMailer/PHPMailer)"); } elseif (is_string($this->XMailer) && trim($this->XMailer) !== '') { $result .= $this->headerLine("X-Mailer", trim($this->XMailer)); } if ('' !== $this->ConfirmReadingTo) { $result .= $this->headerLine("Disposition-Notification-To", "<" . $this->ConfirmReadingTo . ">"); } foreach ($this->CustomHeader as $header) { $result .= $this->headerLine(trim($header[0]), $this->encodeHeader(trim($header[1]))); } if (!$this->sign_key_file) { $result .= $this->headerLine("MIME-Version", "1.0"); $result .= $this->getMailMIME(); } return $result; } public function getMailMIME() { $result = ''; $ismultipart = true; switch ($this->message_type) { case "inline": $result .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_RELATED . ";"); $result .= $this->textLine(" boundary="" . $this->boundary[1] . """); break; case "attach": case "inline_attach": case "alt_attach": case "alt_inline_attach": $result .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_MIXED . ";"); $result .= $this->textLine(" boundary="" . $this->boundary[1] . """); break; case "alt": case "alt_inline": $result .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ";"); $result .= $this->textLine(" boundary="" . $this->boundary[1] . """); break; default: $result .= $this->textLine("Content-Type: " . $this->ContentType . "; charset=" . $this->CharSet); $ismultipart = false; break; } if (static::ENCODING_7BIT !== $this->Encoding) { if ($ismultipart) { if (static::ENCODING_8BIT === $this->Encoding) { $result .= $this->headerLine("Content-Transfer-Encoding", static::ENCODING_8BIT); } } else { $result .= $this->headerLine("Content-Transfer-Encoding", $this->Encoding); } } return $result; } public function getSentMIMEMessage() { return static::stripTrailingWSP($this->MIMEHeader . $this->mailHeader) . static::$LE . static::$LE . $this->MIMEBody; } protected function generateId() { $len = 32; $bytes = ''; if (function_exists("random_bytes")) { try { $bytes = random_bytes($len); } catch (\Exception $e) { } } elseif (function_exists("openssl_random_pseudo_bytes")) { $bytes = openssl_random_pseudo_bytes($len); } if ($bytes === '') { $bytes = hash("sha256", uniqid((string) mt_rand(), true), true); } return str_replace(array("=", "+", "/"), '', base64_encode(hash("sha256", $bytes, true))); } public function createBody() { $body = ''; $this->setBoundaries(); if ($this->sign_key_file) { $body .= $this->getMailMIME() . static::$LE; } $this->setWordWrap(); $bodyEncoding = $this->Encoding; $bodyCharSet = $this->CharSet; if (static::ENCODING_8BIT === $bodyEncoding && !$this->has8bitChars($this->Body)) { $bodyEncoding = static::ENCODING_7BIT; $bodyCharSet = static::CHARSET_ASCII; } if (static::ENCODING_BASE64 !== $this->Encoding && static::hasLineLongerThanMax($this->Body)) { $bodyEncoding = static::ENCODING_QUOTED_PRINTABLE; } $altBodyEncoding = $this->Encoding; $altBodyCharSet = $this->CharSet; if (static::ENCODING_8BIT === $altBodyEncoding && !$this->has8bitChars($this->AltBody)) { $altBodyEncoding = static::ENCODING_7BIT; $altBodyCharSet = static::CHARSET_ASCII; } if (static::ENCODING_BASE64 !== $altBodyEncoding && static::hasLineLongerThanMax($this->AltBody)) { $altBodyEncoding = static::ENCODING_QUOTED_PRINTABLE; } $mimepre = ''; switch ($this->message_type) { case "inline": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("inline", $this->boundary[1]); break; case "attach": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("attachment", $this->boundary[1]); break; case "inline_attach": $body .= $mimepre; $body .= $this->textLine("--" . $this->boundary[1]); $body .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_RELATED . ";"); $body .= $this->textLine(" boundary="" . $this->boundary[2] . "";"); $body .= $this->textLine(" type="" . static::CONTENT_TYPE_TEXT_HTML . """); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("inline", $this->boundary[2]); $body .= static::$LE; $body .= $this->attachAll("attachment", $this->boundary[1]); break; case "alt": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; if (!empty($this->Ical)) { $method = static::ICAL_METHOD_REQUEST; foreach (static::$IcalMethods as $imethod) { if (stripos($this->Ical, "METHOD:" . $imethod) !== false) { $method = $imethod; break; } } $body .= $this->getBoundary($this->boundary[1], '', static::CONTENT_TYPE_TEXT_CALENDAR . "; method=" . $method, ''); $body .= $this->encodeString($this->Ical, $this->Encoding); $body .= static::$LE; } $body .= $this->endBoundary($this->boundary[1]); break; case "alt_inline": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->textLine("--" . $this->boundary[1]); $body .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_RELATED . ";"); $body .= $this->textLine(" boundary="" . $this->boundary[2] . "";"); $body .= $this->textLine(" type="" . static::CONTENT_TYPE_TEXT_HTML . """); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("inline", $this->boundary[2]); $body .= static::$LE; $body .= $this->endBoundary($this->boundary[1]); break; case "alt_attach": $body .= $mimepre; $body .= $this->textLine("--" . $this->boundary[1]); $body .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ";"); $body .= $this->textLine(" boundary="" . $this->boundary[2] . """); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; if (!empty($this->Ical)) { $method = static::ICAL_METHOD_REQUEST; foreach (static::$IcalMethods as $imethod) { if (stripos($this->Ical, "METHOD:" . $imethod) !== false) { $method = $imethod; break; } } $body .= $this->getBoundary($this->boundary[2], '', static::CONTENT_TYPE_TEXT_CALENDAR . "; method=" . $method, ''); $body .= $this->encodeString($this->Ical, $this->Encoding); } $body .= $this->endBoundary($this->boundary[2]); $body .= static::$LE; $body .= $this->attachAll("attachment", $this->boundary[1]); break; case "alt_inline_attach": $body .= $mimepre; $body .= $this->textLine("--" . $this->boundary[1]); $body .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ";"); $body .= $this->textLine(" boundary="" . $this->boundary[2] . """); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->textLine("--" . $this->boundary[2]); $body .= $this->headerLine("Content-Type", static::CONTENT_TYPE_MULTIPART_RELATED . ";"); $body .= $this->textLine(" boundary="" . $this->boundary[3] . "";"); $body .= $this->textLine(" type="" . static::CONTENT_TYPE_TEXT_HTML . """); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("inline", $this->boundary[3]); $body .= static::$LE; $body .= $this->endBoundary($this->boundary[2]); $body .= static::$LE; $body .= $this->attachAll("attachment", $this->boundary[1]); break; default: $this->Encoding = $bodyEncoding; $body .= $this->encodeString($this->Body, $this->Encoding); break; } if ($this->isError()) { $body = ''; if ($this->exceptions) { throw new Exception($this->lang("empty_message"), self::STOP_CRITICAL); } } elseif ($this->sign_key_file) { try { if (!defined("PKCS7_TEXT")) { throw new Exception($this->lang("extension_missing") . "openssl"); } $file = tempnam(sys_get_temp_dir(), "srcsign"); $signed = tempnam(sys_get_temp_dir(), "mailsign"); file_put_contents($file, $body); if (empty($this->sign_extracerts_file)) { $sign = @openssl_pkcs7_sign($file, $signed, "file://" . realpath($this->sign_cert_file), array("file://" . realpath($this->sign_key_file), $this->sign_key_pass), array()); } else { $sign = @openssl_pkcs7_sign($file, $signed, "file://" . realpath($this->sign_cert_file), array("file://" . realpath($this->sign_key_file), $this->sign_key_pass), array(), PKCS7_DETACHED, $this->sign_extracerts_file); } @unlink($file); if ($sign) { $body = file_get_contents($signed); @unlink($signed); $parts = explode("\xa
", $body, 2); $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE; $body = $parts[1]; } else { @unlink($signed); throw new Exception($this->lang("signing") . openssl_error_string()); } } catch (Exception $exc) { $body = ''; if ($this->exceptions) { throw $exc; } } } return $body; } public function getBoundaries() { if (empty($this->boundary)) { $this->setBoundaries(); } return $this->boundary; } protected function getBoundary($boundary, $charSet, $contentType, $encoding) { $result = ''; if ('' === $charSet) { $charSet = $this->CharSet; } if ('' === $contentType) { $contentType = $this->ContentType; } if ('' === $encoding) { $encoding = $this->Encoding; } $result .= $this->textLine("--" . $boundary); $result .= sprintf("Content-Type: %s; charset=%s", $contentType, $charSet); $result .= static::$LE; if (static::ENCODING_7BIT !== $encoding) { $result .= $this->headerLine("Content-Transfer-Encoding", $encoding); } $result .= static::$LE; return $result; } protected function endBoundary($boundary) { return static::$LE . "--" . $boundary . "--" . static::$LE; } protected function setMessageType() { $type = array(); if ($this->alternativeExists()) { $type[] = "alt"; } if ($this->inlineImageExists()) { $type[] = "inline"; } if ($this->attachmentExists()) { $type[] = "attach"; } $this->message_type = implode("_", $type); if ('' === $this->message_type) { $this->message_type = "plain"; } } public function headerLine($name, $value) { return $name . ": " . $value . static::$LE; } public function textLine($value) { return $value . static::$LE; } public function addAttachment($path, $name = '', $encoding = self::ENCODING_BASE64, $type = '', $disposition = "attachment") { try { if (!static::fileIsAccessible($path)) { throw new Exception($this->lang("file_access") . $path, self::STOP_CONTINUE); } if ('' === $type) { $type = static::filenameToType($path); } $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME); if ('' === $name) { $name = $filename; } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("encoding") . $encoding); } $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => $disposition, 7 => $name); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } public function getAttachments() { return $this->attachment; } protected function attachAll($disposition_type, $boundary) { $mime = array(); $cidUniq = array(); $incl = array(); foreach ($this->attachment as $attachment) { if ($attachment[6] === $disposition_type) { $string = ''; $path = ''; $bString = $attachment[5]; if ($bString) { $string = $attachment[0]; } else { $path = $attachment[0]; } $inclhash = hash("sha256", serialize($attachment)); if (in_array($inclhash, $incl, true)) { continue; } $incl[] = $inclhash; $name = $attachment[2]; $encoding = $attachment[3]; $type = $attachment[4]; $disposition = $attachment[6]; $cid = $attachment[7]; if ("inline" === $disposition && array_key_exists($cid, $cidUniq)) { continue; } $cidUniq[$cid] = true; $mime[] = sprintf("--%s%s", $boundary, static::$LE); if (!empty($name)) { $mime[] = sprintf("Content-Type: %s; name=%s%s", $type, static::quotedString($this->encodeHeader($this->secureHeader($name))), static::$LE); } else { $mime[] = sprintf("Content-Type: %s%s", $type, static::$LE); } if (static::ENCODING_7BIT !== $encoding) { $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, static::$LE); } if ((string) $cid !== '' && $disposition === "inline") { $mime[] = "Content-ID: <" . $this->encodeHeader($this->secureHeader($cid)) . ">" . static::$LE; } if (!empty($disposition)) { $encoded_name = $this->encodeHeader($this->secureHeader($name)); if (!empty($encoded_name)) { $mime[] = sprintf("Content-Disposition: %s; filename=%s%s", $disposition, static::quotedString($encoded_name), static::$LE . static::$LE); } else { $mime[] = sprintf("Content-Disposition: %s%s", $disposition, static::$LE . static::$LE); } } else { $mime[] = static::$LE; } if ($bString) { $mime[] = $this->encodeString($string, $encoding); } else { $mime[] = $this->encodeFile($path, $encoding); } if ($this->isError()) { return ''; } $mime[] = static::$LE; } } $mime[] = sprintf("--%s--%s", $boundary, static::$LE); return implode('', $mime); } protected function encodeFile($path, $encoding = self::ENCODING_BASE64) { try { if (!static::fileIsAccessible($path)) { throw new Exception($this->lang("file_open") . $path, self::STOP_CONTINUE); } $file_buffer = file_get_contents($path); if (false === $file_buffer) { throw new Exception($this->lang("file_open") . $path, self::STOP_CONTINUE); } $file_buffer = $this->encodeString($file_buffer, $encoding); return $file_buffer; } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return ''; } } public function encodeString($str, $encoding = self::ENCODING_BASE64) { $encoded = ''; switch (strtolower($encoding)) { case static::ENCODING_BASE64: $encoded = chunk_split(base64_encode($str), static::STD_LINE_LENGTH, static::$LE); break; case static::ENCODING_7BIT: case static::ENCODING_8BIT: $encoded = static::normalizeBreaks($str); if (substr($encoded, -strlen(static::$LE)) !== static::$LE) { $encoded .= static::$LE; } break; case static::ENCODING_BINARY: $encoded = $str; break; case static::ENCODING_QUOTED_PRINTABLE: $encoded = $this->encodeQP($str); break; default: $this->setError($this->lang("encoding") . $encoding); if ($this->exceptions) { throw new Exception($this->lang("encoding") . $encoding); } break; } return $encoded; } public function encodeHeader($str, $position = "text") { $matchcount = 0; switch (strtolower($position)) { case "phrase": if (!preg_match("/[\200-\377]/", $str)) { $encoded = addcslashes($str, "\0..\x1f\177\""); if ($str === $encoded && !preg_match("/[^A-Za-z0-9!#$%&'*+\/=?^_`{|}~ -]/", $str)) { return $encoded; } return ""{$encoded}""; } $matchcount = preg_match_all("/[^\040\041\043-\133\135-\176]/", $str, $matches); break; case "comment": $matchcount = preg_match_all("/[()"]/", $str, $matches); case "text": default: $matchcount += preg_match_all("/[\000-\010\013\014\016-\037\177-\377]/", $str, $matches); break; } if ($this->has8bitChars($str)) { $charset = $this->CharSet; } else { $charset = static::CHARSET_ASCII; } $overhead = 8 + strlen($charset); if ("mail" === $this->Mailer) { $maxlen = static::MAIL_MAX_LINE_LENGTH - $overhead; } else { $maxlen = static::MAX_LINE_LENGTH - $overhead; } if ($matchcount > strlen($str) / 3) { $encoding = "B"; } elseif ($matchcount > 0) { $encoding = "Q"; } elseif (strlen($str) > $maxlen) { $encoding = "Q"; } else { $encoding = false; } switch ($encoding) { case "B": if ($this->hasMultiBytes($str)) { $encoded = $this->base64EncodeWrapMB($str, "
"); } else { $encoded = base64_encode($str); $maxlen -= $maxlen % 4; $encoded = trim(chunk_split($encoded, $maxlen, "
")); } $encoded = preg_replace("/^(.*)$/m", " =?" . $charset . "?{$encoding}?\1?=", $encoded); break; case "Q": $encoded = $this->encodeQ($str, $position); $encoded = $this->wrapText($encoded, $maxlen, true); $encoded = str_replace("=" . static::$LE, "
", trim($encoded)); $encoded = preg_replace("/^(.*)$/m", " =?" . $charset . "?{$encoding}?\1?=", $encoded); break; default: return $str; } return trim(static::normalizeBreaks($encoded)); } public function hasMultiBytes($str) { if (function_exists("mb_strlen")) { return strlen($str) > mb_strlen($str, $this->CharSet); } return false; } public function has8bitChars($text) { return (bool) preg_match("/[\x80-\xFF]/", $text); } public function base64EncodeWrapMB($str, $linebreak = null) { $start = "=?" . $this->CharSet . "?B?"; $end = "?="; $encoded = ''; if (null === $linebreak) { $linebreak = static::$LE; } $mb_length = mb_strlen($str, $this->CharSet); $length = 75 - strlen($start) - strlen($end); $ratio = $mb_length / strlen($str); $avgLength = floor($length * $ratio * 0.75); $offset = 0; for ($i = 0; $i < $mb_length; $i += $offset) { $lookBack = 0; do { $offset = $avgLength - $lookBack; $chunk = mb_substr($str, $i, $offset, $this->CharSet); $chunk = base64_encode($chunk); ++$lookBack; } while (strlen($chunk) > $length); $encoded .= $chunk . $linebreak; } return substr($encoded, 0, -strlen($linebreak)); } public function encodeQP($string) { return static::normalizeBreaks(quoted_printable_encode($string)); } public function encodeQ($str, $position = "text") { $pattern = ''; $encoded = str_replace(array("\xd", "\xa"), '', $str); switch (strtolower($position)) { case "phrase": $pattern = "^A-Za-z0-9!*+\/ -"; break; case "comment": $pattern = "\(\)""; case "text": default: $pattern = "\000-\011\013\014\016-\037\075\077\137\177-\377" . $pattern; break; } $matches = array(); if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { $eqkey = array_search("=", $matches[0], true); if (false !== $eqkey) { unset($matches[0][$eqkey]); array_unshift($matches[0], "="); } foreach (array_unique($matches[0]) as $char) { $encoded = str_replace($char, "=" . sprintf("%02X", ord($char)), $encoded); } } return str_replace(" ", "_", $encoded); } public function addStringAttachment($string, $filename, $encoding = self::ENCODING_BASE64, $type = '', $disposition = "attachment") { try { if ('' === $type) { $type = static::filenameToType($filename); } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("encoding") . $encoding); } $this->attachment[] = array(0 => $string, 1 => $filename, 2 => static::mb_pathinfo($filename, PATHINFO_BASENAME), 3 => $encoding, 4 => $type, 5 => true, 6 => $disposition, 7 => 0); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } public function addEmbeddedImage($path, $cid, $name = '', $encoding = self::ENCODING_BASE64, $type = '', $disposition = "inline") { try { if (!static::fileIsAccessible($path)) { throw new Exception($this->lang("file_access") . $path, self::STOP_CONTINUE); } if ('' === $type) { $type = static::filenameToType($path); } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("encoding") . $encoding); } $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME); if ('' === $name) { $name = $filename; } $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => $disposition, 7 => $cid); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } public function addStringEmbeddedImage($string, $cid, $name = '', $encoding = self::ENCODING_BASE64, $type = '', $disposition = "inline") { try { if ('' === $type && !empty($name)) { $type = static::filenameToType($name); } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("encoding") . $encoding); } $this->attachment[] = array(0 => $string, 1 => $name, 2 => $name, 3 => $encoding, 4 => $type, 5 => true, 6 => $disposition, 7 => $cid); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } protected function validateEncoding($encoding) { return in_array($encoding, array(self::ENCODING_7BIT, self::ENCODING_QUOTED_PRINTABLE, self::ENCODING_BASE64, self::ENCODING_8BIT, self::ENCODING_BINARY), true); } protected function cidExists($cid) { foreach ($this->attachment as $attachment) { if ("inline" === $attachment[6] && $cid === $attachment[7]) { return true; } } return false; } public function inlineImageExists() { foreach ($this->attachment as $attachment) { if ("inline" === $attachment[6]) { return true; } } return false; } public function attachmentExists() { foreach ($this->attachment as $attachment) { if ("attachment" === $attachment[6]) { return true; } } return false; } public function alternativeExists() { return !empty($this->AltBody); } public function clearQueuedAddresses($kind) { $this->RecipientsQueue = array_filter($this->RecipientsQueue, static function ($params) use($kind) { return $params[0] !== $kind; }); } public function clearAddresses() { foreach ($this->to as $to) { unset($this->all_recipients[strtolower($to[0])]); } $this->to = array(); $this->clearQueuedAddresses("to"); } public function clearCCs() { foreach ($this->cc as $cc) { unset($this->all_recipients[strtolower($cc[0])]); } $this->cc = array(); $this->clearQueuedAddresses("cc"); } public function clearBCCs() { foreach ($this->bcc as $bcc) { unset($this->all_recipients[strtolower($bcc[0])]); } $this->bcc = array(); $this->clearQueuedAddresses("bcc"); } public function clearReplyTos() { $this->ReplyTo = array(); $this->ReplyToQueue = array(); } public function clearAllRecipients() { $this->to = array(); $this->cc = array(); $this->bcc = array(); $this->all_recipients = array(); $this->RecipientsQueue = array(); } public function clearAttachments() { $this->attachment = array(); } public function clearCustomHeaders() { $this->CustomHeader = array(); } public function clearCustomHeader($name, $value = null) { if (null === $value && strpos($name, ":") !== false) { list($name, $value) = explode(":", $name, 2); } $name = trim($name); $value = null === $value ? null : trim($value); foreach ($this->CustomHeader as $k => $pair) { if ($pair[0] == $name) { if (null === $value || $pair[1] == $value) { unset($this->CustomHeader[$k]); } } } return true; } public function replaceCustomHeader($name, $value = null) { if (null === $value && strpos($name, ":") !== false) { list($name, $value) = explode(":", $name, 2); } $name = trim($name); $value = null === $value ? '' : trim($value); $replaced = false; foreach ($this->CustomHeader as $k => $pair) { if ($pair[0] == $name) { if ($replaced) { unset($this->CustomHeader[$k]); continue; } if (strpbrk($name . $value, "
\xa") !== false) { if ($this->exceptions) { throw new Exception($this->lang("invalid_header")); } return false; } $this->CustomHeader[$k] = array($name, $value); $replaced = true; } } return true; } protected function setError($msg) { ++$this->error_count; if ("smtp" === $this->Mailer && null !== $this->smtp) { $lasterror = $this->smtp->getError(); if (!empty($lasterror["error"])) { $msg .= $this->lang("smtp_error") . $lasterror["error"]; if (!empty($lasterror["detail"])) { $msg .= " " . $this->lang("smtp_detail") . $lasterror["detail"]; } if (!empty($lasterror["smtp_code"])) { $msg .= " " . $this->lang("smtp_code") . $lasterror["smtp_code"]; } if (!empty($lasterror["smtp_code_ex"])) { $msg .= " " . $this->lang("smtp_code_ex") . $lasterror["smtp_code_ex"]; } } } $this->ErrorInfo = $msg; } public static function rfcDate() { date_default_timezone_set(@date_default_timezone_get()); return date("D, j M Y H:i:s O"); } protected function serverHostname() { $result = ''; if (!empty($this->Hostname)) { $result = $this->Hostname; } elseif (isset($_SERVER) && array_key_exists("SERVER_NAME", $_SERVER)) { $result = $_SERVER["SERVER_NAME"]; } elseif (function_exists("gethostname") && gethostname() !== false) { $result = gethostname(); } elseif (php_uname("n") !== false) { $result = php_uname("n"); } if (!static::isValidHost($result)) { return "localhost.localdomain"; } return $result; } public static function isValidHost($host) { if (empty($host) || !is_string($host) || strlen($host) > 256 || !preg_match("/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+\])$/", $host)) { return false; } if (strlen($host) > 2 && substr($host, 0, 1) === "[" && substr($host, -1, 1) === "]") { return filter_var(substr($host, 1, -1), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false; } if (is_numeric(str_replace(".", '', $host))) { return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false; } return filter_var("https://" . $host, FILTER_VALIDATE_URL) !== false; } protected function lang($key) { if (count($this->language) < 1) { $this->setLanguage(); } if (array_key_exists($key, $this->language)) { if ("smtp_connect_failed" === $key) { return $this->language[$key] . " https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"; } return $this->language[$key]; } return $key; } private function getSmtpErrorMessage($base_key) { $message = $this->lang($base_key); $error = $this->smtp->getError(); if (!empty($error["error"])) { $message .= " " . $error["error"]; if (!empty($error["detail"])) { $message .= " " . $error["detail"]; } } return $message; } public function isError() { return $this->error_count > 0; } public function addCustomHeader($name, $value = null) { if (null === $value && strpos($name, ":") !== false) { list($name, $value) = explode(":", $name, 2); } $name = trim($name); $value = null === $value ? '' : trim($value); if (empty($name) || strpbrk($name . $value, "
") !== false) { if ($this->exceptions) { throw new Exception($this->lang("invalid_header")); } return false; } $this->CustomHeader[] = array($name, $value); return true; } public function getCustomHeaders() { return $this->CustomHeader; } public function msgHTML($message, $basedir = '', $advanced = false) { preg_match_all("/(?<!-)(src|background)=["'](.*)["']/Ui", $message, $images); if (array_key_exists(2, $images)) { if (strlen($basedir) > 1 && "/" !== substr($basedir, -1)) { $basedir .= "/"; } foreach ($images[2] as $imgindex => $url) { $match = array(); if (preg_match("#^data:(image/(?:jpe?g|gif|png));?(base64)?,(.+)#", $url, $match)) { if (count($match) === 4 && static::ENCODING_BASE64 === $match[2]) { $data = base64_decode($match[3]); } elseif ('' === $match[2]) { $data = rawurldecode($match[3]); } else { continue; } $cid = substr(hash("sha256", $data), 0, 32) . "@phpmailer.0"; if (!$this->cidExists($cid)) { $this->addStringEmbeddedImage($data, $cid, "embed" . $imgindex, static::ENCODING_BASE64, $match[1]); } $message = str_replace($images[0][$imgindex], $images[1][$imgindex] . "="cid:" . $cid . """, $message); continue; } if (!empty($basedir) && strpos($url, "..") === false && 0 !== strpos($url, "cid:") && !preg_match("#^[a-z][a-z0-9+.-]*:?//#i", $url)) { $filename = static::mb_pathinfo($url, PATHINFO_BASENAME); $directory = dirname($url); if ("." === $directory) { $directory = ''; } $cid = substr(hash("sha256", $url), 0, 32) . "@phpmailer.0"; if (strlen($basedir) > 1 && "/" !== substr($basedir, -1)) { $basedir .= "/"; } if (strlen($directory) > 1 && "/" !== substr($directory, -1)) { $directory .= "/"; } if ($this->addEmbeddedImage($basedir . $directory . $filename, $cid, $filename, static::ENCODING_BASE64, static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION)))) { $message = preg_replace("/" . $images[1][$imgindex] . "=["']" . preg_quote($url, "/") . "["']/Ui", $images[1][$imgindex] . "="cid:" . $cid . """, $message); } } } } $this->isHTML(); $this->Body = static::normalizeBreaks($message); $this->AltBody = static::normalizeBreaks($this->html2text($message, $advanced)); if (!$this->alternativeExists()) { $this->AltBody = "This is an HTML-only message. To view it, activate HTML in your email application." . static::$LE; } return $this->Body; } public function html2text($html, $advanced = false) { if (is_callable($advanced)) { return call_user_func($advanced, $html); } return html_entity_decode(trim(strip_tags(preg_replace("/<(head|title|style|script)[^>]*>.*?<\/\1>/si", '', $html))), ENT_QUOTES, $this->CharSet); } public static function _mime_types($ext = '') { $mimes = array("xl" => "application/excel", "js" => "application/javascript", "hqx" => "application/mac-binhex40", "cpt" => "application/mac-compactpro", "bin" => "application/macbinary", "doc" => "application/msword", "word" => "application/msword", "xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xltx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "potx" => "application/vnd.openxmlformats-officedocument.presentationml.template", "ppsx" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "sldx" => "application/vnd.openxmlformats-officedocument.presentationml.slide", "docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "dotx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "xlam" => "application/vnd.ms-excel.addin.macroEnabled.12", "xlsb" => "application/vnd.ms-excel.sheet.binary.macroEnabled.12", "class" => "application/octet-stream", "dll" => "application/octet-stream", "dms" => "application/octet-stream", "exe" => "application/octet-stream", "lha" => "application/octet-stream", "lzh" => "application/octet-stream", "psd" => "application/octet-stream", "sea" => "application/octet-stream", "so" => "application/octet-stream", "oda" => "application/oda", "pdf" => "application/pdf", "ai" => "application/postscript", "eps" => "application/postscript", "ps" => "application/postscript", "smi" => "application/smil", "smil" => "application/smil", "mif" => "application/vnd.mif", "xls" => "application/vnd.ms-excel", "ppt" => "application/vnd.ms-powerpoint", "wbxml" => "application/vnd.wap.wbxml", "wmlc" => "application/vnd.wap.wmlc", "dcr" => "application/x-director", "dir" => "application/x-director", "dxr" => "application/x-director", "dvi" => "application/x-dvi", "gtar" => "application/x-gtar", "php3" => "application/x-httpd-php", "php4" => "application/x-httpd-php", "php" => "application/x-httpd-php", "phtml" => "application/x-httpd-php", "phps" => "application/x-httpd-php-source", "swf" => "application/x-shockwave-flash", "sit" => "application/x-stuffit", "tar" => "application/x-tar", "tgz" => "application/x-tar", "xht" => "application/xhtml+xml", "xhtml" => "application/xhtml+xml", "zip" => "application/zip", "mid" => "audio/midi", "midi" => "audio/midi", "mp2" => "audio/mpeg", "mp3" => "audio/mpeg", "m4a" => "audio/mp4", "mpga" => "audio/mpeg", "aif" => "audio/x-aiff", "aifc" => "audio/x-aiff", "aiff" => "audio/x-aiff", "ram" => "audio/x-pn-realaudio", "rm" => "audio/x-pn-realaudio", "rpm" => "audio/x-pn-realaudio-plugin", "ra" => "audio/x-realaudio", "wav" => "audio/x-wav", "mka" => "audio/x-matroska", "bmp" => "image/bmp", "gif" => "image/gif", "jpeg" => "image/jpeg", "jpe" => "image/jpeg", "jpg" => "image/jpeg", "png" => "image/png", "tiff" => "image/tiff", "tif" => "image/tiff", "webp" => "image/webp", "avif" => "image/avif", "heif" => "image/heif", "heifs" => "image/heif-sequence", "heic" => "image/heic", "heics" => "image/heic-sequence", "eml" => "message/rfc822", "css" => "text/css", "html" => "text/html", "htm" => "text/html", "shtml" => "text/html", "log" => "text/plain", "text" => "text/plain", "txt" => "text/plain", "rtx" => "text/richtext", "rtf" => "text/rtf", "vcf" => "text/vcard", "vcard" => "text/vcard", "ics" => "text/calendar", "xml" => "text/xml", "xsl" => "text/xml", "csv" => "text/csv", "wmv" => "video/x-ms-wmv", "mpeg" => "video/mpeg", "mpe" => "video/mpeg", "mpg" => "video/mpeg", "mp4" => "video/mp4", "m4v" => "video/mp4", "mov" => "video/quicktime", "qt" => "video/quicktime", "rv" => "video/vnd.rn-realvideo", "avi" => "video/x-msvideo", "movie" => "video/x-sgi-movie", "webm" => "video/webm", "mkv" => "video/x-matroska"); $ext = strtolower($ext); if (array_key_exists($ext, $mimes)) { return $mimes[$ext]; } return "application/octet-stream"; } public static function filenameToType($filename) { $qpos = strpos($filename, "?"); if (false !== $qpos) { $filename = substr($filename, 0, $qpos); } $ext = static::mb_pathinfo($filename, PATHINFO_EXTENSION); return static::_mime_types($ext); } public static function mb_pathinfo($path, $options = null) { $ret = array("dirname" => '', "basename" => '', "extension" => '', "filename" => ''); $pathinfo = array(); if (preg_match("#^(.*?)[\\/]*(([^/\\]*?)(\.([^.\\/]+?)|))[\\/.]*$#m", $path, $pathinfo)) { if (array_key_exists(1, $pathinfo)) { $ret["dirname"] = $pathinfo[1]; } if (array_key_exists(2, $pathinfo)) { $ret["basename"] = $pathinfo[2]; } if (array_key_exists(5, $pathinfo)) { $ret["extension"] = $pathinfo[5]; } if (array_key_exists(3, $pathinfo)) { $ret["filename"] = $pathinfo[3]; } } switch ($options) { case PATHINFO_DIRNAME: case "dirname": return $ret["dirname"]; case PATHINFO_BASENAME: case "basename": return $ret["basename"]; case PATHINFO_EXTENSION: case "extension": return $ret["extension"]; case PATHINFO_FILENAME: case "filename": return $ret["filename"]; default: return $ret; } } public function set($name, $value = '') { if (property_exists($this, $name)) { $this->{$name} = $value; return true; } $this->setError($this->lang("variable_set") . $name); return false; } public function secureHeader($str) { return trim(str_replace(array("
", "
"), '', $str)); } public static function normalizeBreaks($text, $breaktype = null) { if (null === $breaktype) { $breaktype = static::$LE; } $text = str_replace(array(self::CRLF, "\xd"), "
", $text); if ("
" !== $breaktype) { $text = str_replace("\xa", $breaktype, $text); } return $text; } public static function stripTrailingWSP($text) { return rtrim($text, " \xd\xa\x9"); } public static function stripTrailingBreaks($text) { return rtrim($text, "\xd
"); } public static function getLE() { return static::$LE; } protected static function setLE($le) { static::$LE = $le; } public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '') { $this->sign_cert_file = $cert_filename; $this->sign_key_file = $key_filename; $this->sign_key_pass = $key_pass; $this->sign_extracerts_file = $extracerts_filename; } public function DKIM_QP($txt) { $line = ''; $len = strlen($txt); for ($i = 0; $i < $len; ++$i) { $ord = ord($txt[$i]); if (33 <= $ord && $ord <= 58 || $ord === 60 || 62 <= $ord && $ord <= 126) { $line .= $txt[$i]; } else { $line .= "=" . sprintf("%02X", $ord); } } return $line; } public function DKIM_Sign($signHeader) { if (!defined("PKCS7_TEXT")) { if ($this->exceptions) { throw new Exception($this->lang("extension_missing") . "openssl"); } return ''; } $privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private); if ('' !== $this->DKIM_passphrase) { $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); } else { $privKey = openssl_pkey_get_private($privKeyStr); } if (openssl_sign($signHeader, $signature, $privKey, "sha256WithRSAEncryption")) { if (\PHP_MAJOR_VERSION < 8) { openssl_pkey_free($privKey); } return base64_encode($signature); } if (\PHP_MAJOR_VERSION < 8) { openssl_pkey_free($privKey); } return ''; } public function DKIM_HeaderC($signHeader) { $signHeader = static::normalizeBreaks($signHeader, self::CRLF); $signHeader = preg_replace("/\r\n[ \t]+/", " ", $signHeader); $lines = explode(self::CRLF, $signHeader); foreach ($lines as $key => $line) { if (strpos($line, ":") === false) { continue; } list($heading, $value) = explode(":", $line, 2); $heading = strtolower($heading); $value = preg_replace("/[ \t]+/", " ", $value); $lines[$key] = trim($heading, " 	") . ":" . trim($value, " 	"); } return implode(self::CRLF, $lines); } public function DKIM_BodyC($body) { if (empty($body)) { return self::CRLF; } $body = static::normalizeBreaks($body, self::CRLF); return static::stripTrailingBreaks($body) . self::CRLF; } public function DKIM_Add($headers_line, $subject, $body) { $DKIMsignatureType = "rsa-sha256"; $DKIMcanonicalization = "relaxed/simple"; $DKIMquery = "dns/txt"; $DKIMtime = time(); $autoSignHeaders = array("from", "to", "cc", "date", "subject", "reply-to", "message-id", "content-type", "mime-version", "x-mailer"); if (stripos($headers_line, "Subject") === false) { $headers_line .= "Subject: " . $subject . static::$LE; } $headerLines = explode(static::$LE, $headers_line); $currentHeaderLabel = ''; $currentHeaderValue = ''; $parsedHeaders = array(); $headerLineIndex = 0; $headerLineCount = count($headerLines); foreach ($headerLines as $headerLine) { $matches = array(); if (preg_match("/^([^ \t]*?)(?::[ \t]*)(.*)$/", $headerLine, $matches)) { if ($currentHeaderLabel !== '') { $parsedHeaders[] = array("label" => $currentHeaderLabel, "value" => $currentHeaderValue); } $currentHeaderLabel = $matches[1]; $currentHeaderValue = $matches[2]; } elseif (preg_match("/^[ \t]+(.*)$/", $headerLine, $matches)) { $currentHeaderValue .= " " . $matches[1]; } ++$headerLineIndex; if ($headerLineIndex >= $headerLineCount) { $parsedHeaders[] = array("label" => $currentHeaderLabel, "value" => $currentHeaderValue); } } $copiedHeaders = array(); $headersToSignKeys = array(); $headersToSign = array(); foreach ($parsedHeaders as $header) { if (in_array(strtolower($header["label"]), $autoSignHeaders, true)) { $headersToSignKeys[] = $header["label"]; $headersToSign[] = $header["label"] . ": " . $header["value"]; if ($this->DKIM_copyHeaderFields) { $copiedHeaders[] = $header["label"] . ":" . str_replace("|", "=7C", $this->DKIM_QP($header["value"])); } continue; } if (in_array($header["label"], $this->DKIM_extraHeaders, true)) { foreach ($this->CustomHeader as $customHeader) { if ($customHeader[0] === $header["label"]) { $headersToSignKeys[] = $header["label"]; $headersToSign[] = $header["label"] . ": " . $header["value"]; if ($this->DKIM_copyHeaderFields) { $copiedHeaders[] = $header["label"] . ":" . str_replace("|", "=7C", $this->DKIM_QP($header["value"])); } continue 2; } } } } $copiedHeaderFields = ''; if ($this->DKIM_copyHeaderFields && count($copiedHeaders) > 0) { $copiedHeaderFields = " z="; $first = true; foreach ($copiedHeaders as $copiedHeader) { if (!$first) { $copiedHeaderFields .= static::$LE . " |"; } if (strlen($copiedHeader) > self::STD_LINE_LENGTH - 3) { $copiedHeaderFields .= substr(chunk_split($copiedHeader, self::STD_LINE_LENGTH - 3, static::$LE . self::FWS), 0, -strlen(static::$LE . self::FWS)); } else { $copiedHeaderFields .= $copiedHeader; } $first = false; } $copiedHeaderFields .= ";" . static::$LE; } $headerKeys = " h=" . implode(":", $headersToSignKeys) . ";" . static::$LE; $headerValues = implode(static::$LE, $headersToSign); $body = $this->DKIM_BodyC($body); $DKIMb64 = base64_encode(pack("H*", hash("sha256", $body))); $ident = ''; if ('' !== $this->DKIM_identity) { $ident = " i=" . $this->DKIM_identity . ";" . static::$LE; } $dkimSignatureHeader = "DKIM-Signature: v=1;" . " d=" . $this->DKIM_domain . ";" . " s=" . $this->DKIM_selector . ";" . static::$LE . " a=" . $DKIMsignatureType . ";" . " q=" . $DKIMquery . ";" . " t=" . $DKIMtime . ";" . " c=" . $DKIMcanonicalization . ";" . static::$LE . $headerKeys . $ident . $copiedHeaderFields . " bh=" . $DKIMb64 . ";" . static::$LE . " b="; $canonicalizedHeaders = $this->DKIM_HeaderC($headerValues . static::$LE . $dkimSignatureHeader); $signature = $this->DKIM_Sign($canonicalizedHeaders); $signature = trim(chunk_split($signature, self::STD_LINE_LENGTH - 3, static::$LE . self::FWS)); return static::normalizeBreaks($dkimSignatureHeader . $signature); } public static function hasLineLongerThanMax($str) { return (bool) preg_match("/^(.{" . (self::MAX_LINE_LENGTH + strlen(static::$LE)) . ",})/m", $str); } public static function quotedString($str) { if (preg_match("/[ ()<>@,;:"\/\[\]?=]/", $str)) { return """ . str_replace(""", "\"", $str) . """; } return $str; } public function getToAddresses() { return $this->to; } public function getCcAddresses() { return $this->cc; } public function getBccAddresses() { return $this->bcc; } public function getReplyToAddresses() { return $this->ReplyTo; } public function getAllRecipientAddresses() { return $this->all_recipients; } protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra) { if (!empty($this->action_function) && is_callable($this->action_function)) { call_user_func($this->action_function, $isSent, $to, $cc, $bcc, $subject, $body, $from, $extra); } } public function getOAuth() { return $this->oauth; } public function setOAuth(OAuthTokenProvider $oauth) { $this->oauth = $oauth; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace PHPMailer\PHPMailer; class PHPMailer { const CHARSET_ASCII = "\165\163\x2d\x61\163\143\x69\151"; const CHARSET_ISO88591 = "\151\163\157\x2d\70\70\x35\71\55\61"; const CHARSET_UTF8 = "\165\164\x66\x2d\70"; const CONTENT_TYPE_PLAINTEXT = "\164\145\170\164\57\160\x6c\x61\x69\x6e"; const CONTENT_TYPE_TEXT_CALENDAR = "\x74\x65\170\x74\x2f\x63\141\154\x65\x6e\x64\141\162"; const CONTENT_TYPE_TEXT_HTML = "\x74\x65\x78\x74\x2f\x68\x74\x6d\154"; const CONTENT_TYPE_MULTIPART_ALTERNATIVE = "\x6d\165\x6c\164\151\160\141\x72\x74\57\x61\154\164\x65\162\156\141\164\151\166\145"; const CONTENT_TYPE_MULTIPART_MIXED = "\155\165\154\164\x69\x70\x61\x72\x74\57\155\x69\x78\145\144"; const CONTENT_TYPE_MULTIPART_RELATED = "\155\165\x6c\164\x69\160\141\x72\x74\57\x72\x65\x6c\x61\164\x65\x64"; const ENCODING_7BIT = "\x37\x62\x69\164"; const ENCODING_8BIT = "\70\142\151\164"; const ENCODING_BASE64 = "\142\141\x73\x65\x36\64"; const ENCODING_BINARY = "\x62\151\x6e\x61\x72\x79"; const ENCODING_QUOTED_PRINTABLE = "\161\165\x6f\x74\145\144\55\160\162\x69\x6e\164\141\142\x6c\145"; const ENCRYPTION_STARTTLS = "\164\154\163"; const ENCRYPTION_SMTPS = "\163\163\x6c"; const ICAL_METHOD_REQUEST = "\122\105\x51\125\x45\x53\124"; const ICAL_METHOD_PUBLISH = "\120\x55\102\x4c\111\x53\x48"; const ICAL_METHOD_REPLY = "\122\105\120\x4c\131"; const ICAL_METHOD_ADD = "\x41\104\x44"; const ICAL_METHOD_CANCEL = "\103\x41\116\x43\x45\x4c"; const ICAL_METHOD_REFRESH = "\122\x45\106\122\x45\123\110"; const ICAL_METHOD_COUNTER = "\x43\x4f\x55\x4e\124\x45\122"; const ICAL_METHOD_DECLINECOUNTER = "\x44\105\x43\114\111\x4e\105\103\117\125\x4e\124\105\122"; public $Priority; public $CharSet = self::CHARSET_ISO88591; public $ContentType = self::CONTENT_TYPE_PLAINTEXT; public $Encoding = self::ENCODING_8BIT; public $ErrorInfo = ''; public $From = ''; public $FromName = ''; public $Sender = ''; public $Subject = ''; public $Body = ''; public $AltBody = ''; public $Ical = ''; protected static $IcalMethods = array(self::ICAL_METHOD_REQUEST, self::ICAL_METHOD_PUBLISH, self::ICAL_METHOD_REPLY, self::ICAL_METHOD_ADD, self::ICAL_METHOD_CANCEL, self::ICAL_METHOD_REFRESH, self::ICAL_METHOD_COUNTER, self::ICAL_METHOD_DECLINECOUNTER); protected $MIMEBody = ''; protected $MIMEHeader = ''; protected $mailHeader = ''; public $WordWrap = 0; public $Mailer = "\155\x61\x69\x6c"; public $Sendmail = "\x2f\x75\x73\x72\57\x73\x62\151\x6e\x2f\163\x65\x6e\x64\x6d\x61\x69\154"; public $UseSendmailOptions = true; public $ConfirmReadingTo = ''; public $Hostname = ''; public $MessageID = ''; public $MessageDate = ''; public $Host = "\154\157\x63\141\154\x68\157\x73\164"; public $Port = 25; public $Helo = ''; public $SMTPSecure = ''; public $SMTPAutoTLS = true; public $SMTPAuth = false; public $SMTPOptions = array(); public $Username = ''; public $Password = ''; public $AuthType = ''; protected $SMTPXClient = array(); protected $oauth; public $Timeout = 300; public $dsn = ''; public $SMTPDebug = 0; public $Debugoutput = "\145\143\150\157"; public $SMTPKeepAlive = false; public $SingleTo = false; protected $SingleToArray = array(); public $do_verp = false; public $AllowEmpty = false; public $DKIM_selector = ''; public $DKIM_identity = ''; public $DKIM_passphrase = ''; public $DKIM_domain = ''; public $DKIM_copyHeaderFields = true; public $DKIM_extraHeaders = array(); public $DKIM_private = ''; public $DKIM_private_string = ''; public $action_function = ''; public $XMailer = ''; public static $validator = "\160\x68\x70"; protected $smtp; protected $to = array(); protected $cc = array(); protected $bcc = array(); protected $ReplyTo = array(); protected $all_recipients = array(); protected $RecipientsQueue = array(); protected $ReplyToQueue = array(); protected $attachment = array(); protected $CustomHeader = array(); protected $lastMessageID = ''; protected $message_type = ''; protected $boundary = array(); protected $language = array(); protected $error_count = 0; protected $sign_cert_file = ''; protected $sign_key_file = ''; protected $sign_extracerts_file = ''; protected $sign_key_pass = ''; protected $exceptions = false; protected $uniqueid = ''; const VERSION = "\x36\56\x39\x2e\61"; const STOP_MESSAGE = 0; const STOP_CONTINUE = 1; const STOP_CRITICAL = 2; const CRLF = "\15\12"; const FWS = "\40"; protected static $LE = self::CRLF; const MAIL_MAX_LINE_LENGTH = 63; const MAX_LINE_LENGTH = 998; const STD_LINE_LENGTH = 76; public function __construct($exceptions = null) { if (null !== $exceptions) { $this->exceptions = (bool) $exceptions; } $this->Debugoutput = strpos(PHP_SAPI, "\x63\154\151") !== false ? "\x65\143\150\157" : "\150\164\x6d\154"; } public function __destruct() { $this->smtpClose(); } private function mailPassthru($to, $subject, $body, $header, $params) { if ((int) ini_get("\155\x62\163\x74\x72\x69\156\147\56\x66\x75\x6e\143\x5f\157\166\145\x72\154\157\x61\144") & 1) { $subject = $this->secureHeader($subject); } else { $subject = $this->encodeHeader($this->secureHeader($subject)); } $this->edebug("\x53\x65\x6e\x64\151\x6e\147\x20\x77\x69\164\x68\x20\155\x61\151\154\50\51"); $this->edebug("\x53\x65\156\x64\x6d\x61\151\154\40\x70\x61\x74\x68\x3a\40" . ini_get("\x73\145\x6e\144\x6d\x61\x69\x6c\x5f\160\141\x74\x68")); $this->edebug("\x45\156\x76\145\154\157\160\145\x20\163\145\x6e\144\145\162\72\40{$this->Sender}"); $this->edebug("\x54\x6f\x3a\40{$to}"); $this->edebug("\123\x75\142\152\145\x63\164\72\x20{$subject}"); $this->edebug("\110\145\x61\x64\145\162\x73\72\40{$header}"); if (!$this->UseSendmailOptions || null === $params) { $result = @mail($to, $subject, $body, $header); } else { $this->edebug("\x41\144\144\151\x74\151\157\156\x61\x6c\40\160\x61\x72\141\x6d\163\72\x20{$params}"); $result = @mail($to, $subject, $body, $header, $params); } $this->edebug("\x52\145\x73\165\154\x74\x3a\40" . ($result ? "\x74\162\x75\145" : "\146\141\x6c\163\145")); return $result; } protected function edebug($str) { if ($this->SMTPDebug <= 0) { return; } if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) { $this->Debugoutput->debug($str); return; } if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, array("\x65\x72\x72\x6f\162\137\154\157\x67", "\x68\x74\x6d\154", "\145\143\150\x6f"))) { call_user_func($this->Debugoutput, $str, $this->SMTPDebug); return; } switch ($this->Debugoutput) { case "\145\x72\x72\157\162\x5f\154\x6f\x67": error_log($str); break; case "\150\x74\x6d\x6c": echo htmlentities(preg_replace("\57\x5b\x5c\162\x5c\x6e\135\53\x2f", '', $str), ENT_QUOTES, "\x55\124\x46\55\70"), "\x3c\142\x72\x3e\12"; break; case "\x65\143\x68\157": default: $str = preg_replace("\x2f\x5c\162\134\x6e\174\134\162\57\155", "\12", $str); echo gmdate("\131\x2d\x6d\55\x64\40\x48\x3a\151\x3a\x73"), "\11", trim(str_replace("\12", "\12\x20\x20\x20\x20\40\40\40\x20\x20\40\x20\40\40\40\x20\40\40\x20\40\x9\x20\x20\x20\40\x20\40\x20\40\40\40\x20\x20\40\40\40\40\40\40", trim($str))), "\xa"; } } public function isHTML($isHtml = true) { if ($isHtml) { $this->ContentType = static::CONTENT_TYPE_TEXT_HTML; } else { $this->ContentType = static::CONTENT_TYPE_PLAINTEXT; } } public function isSMTP() { $this->Mailer = "\163\x6d\x74\160"; } public function isMail() { $this->Mailer = "\x6d\x61\151\x6c"; } public function isSendmail() { $ini_sendmail_path = ini_get("\x73\x65\156\x64\x6d\141\151\154\137\160\x61\164\x68"); if (false === stripos($ini_sendmail_path, "\163\145\x6e\144\x6d\x61\151\x6c")) { $this->Sendmail = "\57\165\x73\162\x2f\x73\142\x69\156\57\163\x65\156\144\155\141\151\154"; } else { $this->Sendmail = $ini_sendmail_path; } $this->Mailer = "\163\x65\x6e\144\x6d\141\151\154"; } public function isQmail() { $ini_sendmail_path = ini_get("\163\145\156\x64\x6d\141\151\154\x5f\x70\x61\164\x68"); if (false === stripos($ini_sendmail_path, "\161\x6d\x61\x69\x6c")) { $this->Sendmail = "\57\x76\141\162\x2f\161\155\141\151\154\x2f\x62\x69\x6e\x2f\x71\155\141\x69\x6c\x2d\151\x6e\152\x65\x63\164"; } else { $this->Sendmail = $ini_sendmail_path; } $this->Mailer = "\x71\x6d\x61\x69\154"; } public function addAddress($address, $name = '') { return $this->addOrEnqueueAnAddress("\164\157", $address, $name); } public function addCC($address, $name = '') { return $this->addOrEnqueueAnAddress("\x63\143", $address, $name); } public function addBCC($address, $name = '') { return $this->addOrEnqueueAnAddress("\142\x63\143", $address, $name); } public function addReplyTo($address, $name = '') { return $this->addOrEnqueueAnAddress("\122\x65\160\154\171\55\124\x6f", $address, $name); } protected function addOrEnqueueAnAddress($kind, $address, $name) { $pos = false; if ($address !== null) { $address = trim($address); $pos = strrpos($address, "\x40"); } if (false === $pos) { $error_message = sprintf("\45\163\x20\x28\45\x73\x29\x3a\x20\x25\x73", $this->lang("\x69\x6e\166\141\x6c\151\144\137\x61\144\144\x72\145\163\163"), $kind, $address); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } if ($name !== null && is_string($name)) { $name = trim(preg_replace("\57\x5b\x5c\162\x5c\x6e\x5d\x2b\57", '', $name)); } else { $name = ''; } $params = array($kind, $address, $name); if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) { if ("\122\x65\160\x6c\x79\55\124\x6f" !== $kind) { if (!array_key_exists($address, $this->RecipientsQueue)) { $this->RecipientsQueue[$address] = $params; return true; } } elseif (!array_key_exists($address, $this->ReplyToQueue)) { $this->ReplyToQueue[$address] = $params; return true; } return false; } return call_user_func_array(array($this, "\x61\x64\144\x41\x6e\101\144\x64\162\145\x73\163"), $params); } public function setBoundaries() { $this->uniqueid = $this->generateId(); $this->boundary[1] = "\142\x31\x3d\x5f" . $this->uniqueid; $this->boundary[2] = "\142\62\x3d\x5f" . $this->uniqueid; $this->boundary[3] = "\142\x33\x3d\x5f" . $this->uniqueid; } protected function addAnAddress($kind, $address, $name = '') { if (!in_array($kind, array("\x74\x6f", "\x63\143", "\x62\143\143", "\x52\145\x70\154\x79\55\124\x6f"))) { $error_message = sprintf("\45\x73\72\x20\x25\x73", $this->lang("\111\x6e\x76\x61\x6c\x69\144\40\162\x65\x63\151\x70\151\145\x6e\x74\x20\153\x69\156\x64"), $kind); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } if (!static::validateAddress($address)) { $error_message = sprintf("\45\x73\x20\50\x25\163\51\x3a\40\x25\163", $this->lang("\151\156\166\x61\x6c\x69\x64\137\x61\144\x64\162\145\163\x73"), $kind, $address); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } if ("\122\145\160\x6c\x79\x2d\x54\x6f" !== $kind) { if (!array_key_exists(strtolower($address), $this->all_recipients)) { $this->{$kind}[] = array($address, $name); $this->all_recipients[strtolower($address)] = true; return true; } } elseif (!array_key_exists(strtolower($address), $this->ReplyTo)) { $this->ReplyTo[strtolower($address)] = array($address, $name); return true; } return false; } public static function parseAddresses($addrstr, $useimap = true, $charset = self::CHARSET_ISO88591) { $addresses = array(); if ($useimap && function_exists("\151\x6d\141\x70\x5f\162\146\x63\70\62\62\x5f\160\141\162\x73\145\x5f\x61\144\x72\154\151\x73\x74")) { $list = imap_rfc822_parse_adrlist($addrstr, ''); imap_errors(); foreach ($list as $address) { if ("\56\x53\131\x4e\124\101\x58\55\105\122\122\x4f\x52\x2e" !== $address->host && static::validateAddress($address->mailbox . "\100" . $address->host)) { if (property_exists($address, "\160\145\x72\x73\x6f\156\141\154") && defined("\115\x42\x5f\x43\101\123\105\137\125\x50\x50\105\122") && preg_match("\x2f\x5e\75\x5c\x3f\56\52\134\77\x3d\44\x2f\x73", $address->personal)) { $origCharset = mb_internal_encoding(); mb_internal_encoding($charset); $address->personal = str_replace("\137", "\x3d\62\x30", $address->personal); $address->personal = mb_decode_mimeheader($address->personal); mb_internal_encoding($origCharset); } $addresses[] = array("\156\x61\155\145" => property_exists($address, "\160\145\162\x73\x6f\x6e\x61\154") ? $address->personal : '', "\141\144\144\162\x65\163\x73" => $address->mailbox . "\x40" . $address->host); } } } else { $list = explode("\54", $addrstr); foreach ($list as $address) { $address = trim($address); if (strpos($address, "\74") === false) { if (static::validateAddress($address)) { $addresses[] = array("\x6e\141\x6d\145" => '', "\x61\144\144\162\x65\163\x73" => $address); } } else { list($name, $email) = explode("\x3c", $address); $email = trim(str_replace("\x3e", '', $email)); $name = trim($name); if (static::validateAddress($email)) { if (defined("\115\102\x5f\103\x41\123\105\137\x55\120\x50\105\x52") && preg_match("\57\x5e\75\x5c\x3f\x2e\x2a\x5c\77\x3d\x24\57\x73", $name)) { $origCharset = mb_internal_encoding(); mb_internal_encoding($charset); $name = str_replace("\x5f", "\x3d\62\x30", $name); $name = mb_decode_mimeheader($name); mb_internal_encoding($origCharset); } $addresses[] = array("\x6e\x61\155\145" => trim($name, "\47\x22\x20"), "\x61\144\144\162\x65\x73\163" => $email); } } } } return $addresses; } public function setFrom($address, $name = '', $auto = true) { $address = trim((string) $address); $name = trim(preg_replace("\57\x5b\x5c\x72\x5c\x6e\135\x2b\57", '', $name)); $pos = strrpos($address, "\100"); if (false === $pos || (!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) && !static::validateAddress($address)) { $error_message = sprintf("\x25\163\40\50\x46\162\157\x6d\x29\72\x20\45\x73", $this->lang("\x69\x6e\x76\x61\154\x69\x64\x5f\141\144\x64\x72\145\163\x73"), $address); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } $this->From = $address; $this->FromName = $name; if ($auto && empty($this->Sender)) { $this->Sender = $address; } return true; } public function getLastMessageID() { return $this->lastMessageID; } public static function validateAddress($address, $patternselect = null) { if (null === $patternselect) { $patternselect = static::$validator; } if (is_callable($patternselect) && !is_string($patternselect)) { return call_user_func($patternselect, $address); } if (strpos($address, "\12") !== false || strpos($address, "\15") !== false) { return false; } switch ($patternselect) { case "\x70\143\x72\x65": case "\160\143\162\x65\x38": return (bool) preg_match("\x2f\136\x28\x3f\x21\50\x3f\76\50\77\61\51\x22\x3f\50\x3f\x3e\134\134\x5b\x20\55\x7e\x5d\174\133\x5e\42\135\51\x22\x3f\50\x3f\61\51\51\x7b\62\65\x35\x2c\175\51\x28\77\41\50\77\76\x28\77\61\x29\42\x3f\x28\77\x3e\x5c\134\133\x20\55\176\135\174\133\136\42\x5d\51\x22\x3f\x28\x3f\x31\x29\x29\x7b\66\65\x2c\x7d\100\x29" . "\x28\50\x3f\x3e\50\77\76\50\77\76\50\50\77\76\x28\x3f\76\50\77\x3e\x5c\x78\x30\x44\x5c\170\x30\x41\51\77\x5b\134\164\40\x5d\x29\53\x7c\x28\77\76\x5b\134\164\x20\135\52\x5c\x78\60\104\134\x78\x30\101\x29\x3f\x5b\134\164\x20\135\x2b\51\x3f\51\x28\x5c\50\50\77\76\x28\77\62\51" . "\x28\77\76\133\x5c\x78\x30\x31\x2d\x5c\x78\x30\70\x5c\x78\x30\102\x5c\x78\60\x43\134\170\60\x45\55\47\x2a\55\134\x5b\134\x5d\x2d\134\x78\x37\106\135\x7c\134\x5c\133\x5c\x78\x30\60\55\134\x78\x37\x46\x5d\x7c\50\77\x33\x29\51\x29\x2a\x28\77\x32\x29\x5c\51\51\51\x2b\50\x3f\62\x29\51\174\50\77\x32\x29\51\x3f\51" . "\50\x5b\x21\x23\x2d\47\52\53\x5c\57\x2d\x39\x3d\77\136\x2d\176\x2d\135\x2b\x7c\x22\x28\77\76\x28\77\x32\51\x28\x3f\76\133\134\170\x30\x31\x2d\x5c\170\x30\70\x5c\170\60\102\134\170\60\103\134\170\x30\x45\x2d\x21\x23\55\x5c\133\134\135\55\134\x78\67\106\135\174\x5c\134\x5b\134\x78\x30\x30\55\134\170\x37\x46\135\x29\x29\x2a" . "\x28\x3f\62\51\x22\x29\50\77\x3e\x28\77\61\51\134\x2e\x28\77\61\x29\50\77\x34\51\x29\x2a\50\x3f\61\51\100\x28\x3f\41\x28\x3f\61\x29\133\141\x2d\172\x30\55\x39\55\135\173\x36\x34\x2c\175\51\50\x3f\61\51\50\x3f\x3e\x28\133\141\x2d\172\60\55\x39\135\x28\x3f\76\133\141\x2d\x7a\60\55\x39\x2d\135\52\133\141\x2d\x7a\60\x2d\x39\x5d\51\x3f\x29" . "\x28\x3f\76\x28\77\61\x29\x5c\56\50\77\41\50\77\x31\x29\133\x61\55\x7a\60\55\71\x2d\135\x7b\x36\64\x2c\175\x29\50\x3f\x31\51\50\77\x35\51\51\x7b\60\x2c\x31\62\66\x7d\x7c\134\x5b\50\77\x3a\50\x3f\76\x49\x50\166\x36\72\50\x3f\76\x28\133\x61\55\146\60\x2d\71\135\173\61\54\x34\175\x29\x28\x3f\76\x3a\x28\x3f\66\x29\x29\173\67\x7d" . "\174\50\77\41\50\x3f\72\x2e\52\x5b\141\x2d\146\x30\x2d\x39\x5d\x5b\72\x5c\135\135\51\x7b\70\54\x7d\51\50\x28\x3f\x36\51\x28\77\76\72\50\77\66\x29\51\x7b\60\54\x36\x7d\51\77\x3a\72\x28\77\x37\51\x3f\x29\x29\174\x28\x3f\76\50\x3f\76\x49\120\166\x36\72\x28\77\x3e\50\77\66\51\50\77\76\x3a\50\x3f\66\x29\x29\173\x35\175\72" . "\x7c\50\77\41\x28\77\x3a\x2e\52\x5b\141\55\x66\x30\55\x39\x5d\72\51\x7b\66\54\175\51\x28\x3f\x38\51\x3f\72\72\50\x3f\76\50\x28\77\x36\51\50\77\76\72\x28\77\x36\x29\x29\x7b\x30\54\64\175\x29\x3a\51\77\x29\x29\77\50\62\65\133\x30\55\65\x5d\174\x32\133\60\x2d\64\x5d\133\60\55\71\135\x7c\x31\x5b\60\55\x39\x5d\173\62\x7d" . "\174\x5b\61\x2d\71\135\x3f\x5b\x30\55\71\135\51\x28\77\76\x5c\56\50\x3f\71\x29\x29\173\63\175\x29\51\134\135\x29\50\x3f\61\x29\x24\x2f\151\x73\104", $address); case "\x68\164\155\154\65": return (bool) preg_match("\57\136\x5b\141\x2d\x7a\101\x2d\132\x30\55\71\56\41\x23\44\45\46\x27\x2a\53\134\x2f\75\x3f\x5e\x5f\140\173\x7c\175\176\55\135\x2b\x40\133\x61\x2d\x7a\x41\x2d\132\60\x2d\71\x5d\x28\77\72\133\x61\x2d\x7a\x41\x2d\132\60\x2d\x39\x2d\x5d\x7b\60\54\x36\61\175" . "\x5b\141\x2d\x7a\x41\x2d\x5a\60\55\71\x5d\x29\x3f\50\x3f\72\134\56\x5b\x61\x2d\172\101\55\x5a\60\x2d\x39\135\50\x3f\72\x5b\141\55\172\101\55\x5a\60\x2d\71\55\135\x7b\60\54\66\x31\x7d\133\x61\x2d\172\101\55\132\x30\55\x39\135\51\77\x29\x2a\44\x2f\163\x44", $address); case "\160\x68\x70": default: return filter_var($address, FILTER_VALIDATE_EMAIL) !== false; } } public static function idnSupported() { return function_exists("\x69\144\x6e\x5f\164\x6f\x5f\x61\x73\143\x69\x69") && function_exists("\155\142\x5f\x63\157\x6e\x76\145\162\x74\x5f\145\x6e\143\x6f\144\x69\x6e\147"); } public function punyencodeAddress($address) { $pos = strrpos($address, "\100"); if (!empty($this->CharSet) && false !== $pos && static::idnSupported()) { $domain = substr($address, ++$pos); if ($this->has8bitChars($domain) && @mb_check_encoding($domain, $this->CharSet)) { $domain = mb_convert_encoding($domain, self::CHARSET_UTF8, $this->CharSet); $errorcode = 0; if (defined("\x49\x4e\124\x4c\x5f\x49\104\116\101\x5f\x56\101\122\x49\101\116\x54\x5f\125\124\123\64\x36")) { $punycode = idn_to_ascii($domain, \IDNA_DEFAULT | \IDNA_USE_STD3_RULES | \IDNA_CHECK_BIDI | \IDNA_CHECK_CONTEXTJ | \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46); } elseif (defined("\x49\x4e\124\x4c\x5f\111\x44\x4e\x41\x5f\126\101\x52\x49\x41\x4e\x54\x5f\62\x30\60\x33")) { $punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_2003); } else { $punycode = idn_to_ascii($domain, $errorcode); } if (false !== $punycode) { return substr($address, 0, $pos) . $punycode; } } } return $address; } public function send() { try { if (!$this->preSend()) { return false; } return $this->postSend(); } catch (Exception $exc) { $this->mailHeader = ''; $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } } public function preSend() { if ("\x73\x6d\x74\160" === $this->Mailer || "\x6d\141\x69\x6c" === $this->Mailer && (\PHP_VERSION_ID >= 80000 || stripos(PHP_OS, "\x57\111\x4e") === 0)) { static::setLE(self::CRLF); } else { static::setLE(PHP_EOL); } if ("\x6d\141\x69\x6c" === $this->Mailer && (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70017 || \PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70103) && ini_get("\x6d\141\x69\x6c\x2e\141\x64\x64\x5f\170\x5f\x68\x65\x61\x64\x65\162") === "\x31" && stripos(PHP_OS, "\x57\111\116") === 0) { trigger_error($this->lang("\142\165\147\x67\x79\137\x70\x68\160"), E_USER_WARNING); } try { $this->error_count = 0; $this->mailHeader = ''; foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { $params[1] = $this->punyencodeAddress($params[1]); call_user_func_array(array($this, "\x61\x64\144\101\156\x41\144\x64\162\145\163\163"), $params); } if (count($this->to) + count($this->cc) + count($this->bcc) < 1) { throw new Exception($this->lang("\x70\x72\157\166\151\144\x65\x5f\x61\x64\144\162\x65\x73\x73"), self::STOP_CRITICAL); } foreach (array("\106\162\157\x6d", "\x53\x65\x6e\x64\x65\x72", "\x43\x6f\x6e\146\151\162\155\122\x65\x61\144\x69\156\x67\x54\157") as $address_kind) { if ($this->{$address_kind} === null) { $this->{$address_kind} = ''; continue; } $this->{$address_kind} = trim($this->{$address_kind}); if (empty($this->{$address_kind})) { continue; } $this->{$address_kind} = $this->punyencodeAddress($this->{$address_kind}); if (!static::validateAddress($this->{$address_kind})) { $error_message = sprintf("\45\163\x20\x28\45\x73\51\72\x20\x25\163", $this->lang("\151\156\x76\141\x6c\x69\x64\x5f\x61\144\144\162\x65\x73\x73"), $address_kind, $this->{$address_kind}); $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new Exception($error_message); } return false; } } if ($this->alternativeExists()) { $this->ContentType = static::CONTENT_TYPE_MULTIPART_ALTERNATIVE; } $this->setMessageType(); if (!$this->AllowEmpty && empty($this->Body)) { throw new Exception($this->lang("\x65\x6d\160\164\171\137\155\145\163\163\141\x67\x65"), self::STOP_CRITICAL); } $this->Subject = trim($this->Subject); $this->MIMEHeader = ''; $this->MIMEBody = $this->createBody(); $tempheaders = $this->MIMEHeader; $this->MIMEHeader = $this->createHeader(); $this->MIMEHeader .= $tempheaders; if ("\x6d\x61\x69\154" === $this->Mailer) { if (count($this->to) > 0) { $this->mailHeader .= $this->addrAppend("\124\x6f", $this->to); } else { $this->mailHeader .= $this->headerLine("\x54\x6f", "\165\156\144\151\163\x63\x6c\157\x73\145\x64\55\x72\145\x63\x69\x70\x69\145\156\164\163\x3a\73"); } $this->mailHeader .= $this->headerLine("\123\165\142\152\x65\x63\164", $this->encodeHeader($this->secureHeader($this->Subject))); } if (!empty($this->DKIM_domain) && !empty($this->DKIM_selector) && (!empty($this->DKIM_private_string) || !empty($this->DKIM_private) && static::isPermittedPath($this->DKIM_private) && file_exists($this->DKIM_private))) { $header_dkim = $this->DKIM_Add($this->MIMEHeader . $this->mailHeader, $this->encodeHeader($this->secureHeader($this->Subject)), $this->MIMEBody); $this->MIMEHeader = static::stripTrailingWSP($this->MIMEHeader) . static::$LE . static::normalizeBreaks($header_dkim) . static::$LE; } return true; } catch (Exception $exc) { $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } } public function postSend() { try { switch ($this->Mailer) { case "\163\145\156\144\155\141\151\154": case "\161\x6d\141\151\x6c": return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); case "\x73\155\164\x70": return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); case "\155\x61\x69\154": return $this->mailSend($this->MIMEHeader, $this->MIMEBody); default: $sendMethod = $this->Mailer . "\x53\145\156\144"; if (method_exists($this, $sendMethod)) { return $this->{$sendMethod}($this->MIMEHeader, $this->MIMEBody); } return $this->mailSend($this->MIMEHeader, $this->MIMEBody); } } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->Mailer === "\163\155\x74\160" && $this->SMTPKeepAlive == true && $this->smtp->connected()) { $this->smtp->reset(); } if ($this->exceptions) { throw $exc; } } return false; } protected function sendmailSend($header, $body) { if ($this->Mailer === "\x71\155\141\x69\154") { $this->edebug("\x53\145\156\144\x69\156\x67\40\x77\151\164\x68\x20\x71\x6d\141\151\154"); } else { $this->edebug("\x53\145\156\144\151\x6e\x67\x20\x77\151\x74\150\40\x73\x65\x6e\x64\x6d\x61\x69\154"); } $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; $sendmail_from_value = ini_get("\163\x65\x6e\144\x6d\x61\x69\154\x5f\x66\162\x6f\155"); if (empty($this->Sender) && !empty($sendmail_from_value)) { $this->Sender = ini_get("\x73\x65\x6e\x64\x6d\141\x69\x6c\x5f\x66\162\157\x6d"); } if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) { if ($this->Mailer === "\x71\155\141\x69\154") { $sendmailFmt = "\x25\163\x20\55\x66\x25\x73"; } else { $sendmailFmt = "\x25\163\40\55\157\x69\40\55\x66\x25\x73\40\55\x74"; } } else { $sendmailFmt = "\x25\163\x20\55\157\151\x20\x2d\x74"; } $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); $this->edebug("\123\x65\x6e\144\x6d\141\151\154\x20\x70\141\164\150\x3a\x20" . $this->Sendmail); $this->edebug("\123\145\156\x64\x6d\141\x69\154\40\143\x6f\155\x6d\x61\x6e\144\x3a\x20" . $sendmail); $this->edebug("\x45\156\x76\145\x6c\x6f\x70\x65\x20\163\x65\156\x64\145\x72\x3a\40" . $this->Sender); $this->edebug("\x48\x65\x61\x64\145\x72\163\x3a\x20{$header}"); if ($this->SingleTo) { foreach ($this->SingleToArray as $toAddr) { $mail = @popen($sendmail, "\x77"); if (!$mail) { throw new Exception($this->lang("\145\x78\x65\x63\x75\164\145") . $this->Sendmail, self::STOP_CRITICAL); } $this->edebug("\x54\157\72\x20{$toAddr}"); fwrite($mail, "\x54\x6f\x3a\x20" . $toAddr . "\xa"); fwrite($mail, $header); fwrite($mail, $body); $result = pclose($mail); $addrinfo = static::parseAddresses($toAddr, true, $this->CharSet); $this->doCallback($result === 0, array(array($addrinfo["\141\x64\144\162\x65\x73\163"], $addrinfo["\156\x61\x6d\x65"])), $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); $this->edebug("\x52\145\x73\165\x6c\164\72\x20" . ($result === 0 ? "\164\162\x75\x65" : "\x66\x61\x6c\x73\145")); if (0 !== $result) { throw new Exception($this->lang("\x65\170\x65\143\x75\164\145") . $this->Sendmail, self::STOP_CRITICAL); } } } else { $mail = @popen($sendmail, "\x77"); if (!$mail) { throw new Exception($this->lang("\145\x78\x65\143\165\164\145") . $this->Sendmail, self::STOP_CRITICAL); } fwrite($mail, $header); fwrite($mail, $body); $result = pclose($mail); $this->doCallback($result === 0, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); $this->edebug("\x52\145\x73\x75\154\164\72\x20" . ($result === 0 ? "\x74\162\165\145" : "\146\141\154\x73\145")); if (0 !== $result) { throw new Exception($this->lang("\x65\x78\145\x63\165\x74\x65") . $this->Sendmail, self::STOP_CRITICAL); } } return true; } protected static function isShellSafe($string) { if (!function_exists("\x65\x73\x63\141\x70\x65\163\150\145\x6c\154\x61\162\x67") || !function_exists("\x65\163\143\x61\160\x65\163\x68\x65\x6c\154\143\155\144")) { return false; } if (escapeshellcmd($string) !== $string || !in_array(escapeshellarg($string), array("\x27{$string}\47", "\x22{$string}\x22"))) { return false; } $length = strlen($string); for ($i = 0; $i < $length; ++$i) { $c = $string[$i]; if (!ctype_alnum($c) && strpos("\100\x5f\x2d\56", $c) === false) { return false; } } return true; } protected static function isPermittedPath($path) { return !preg_match("\43\x5e\x5b\141\55\172\x5d\133\141\x2d\x7a\x5c\144\53\x2e\x2d\135\52\72\x2f\57\x23\x69", $path); } protected static function fileIsAccessible($path) { if (!static::isPermittedPath($path)) { return false; } $readable = is_file($path); if (strpos($path, "\134\x5c") !== 0) { $readable = $readable && is_readable($path); } return $readable; } protected function mailSend($header, $body) { $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; $toArr = array(); foreach ($this->to as $toaddr) { $toArr[] = $this->addrFormat($toaddr); } $to = trim(implode("\54\40", $toArr)); if ($to === '') { $to = "\x75\x6e\x64\151\x73\x63\154\157\163\x65\x64\55\162\x65\143\151\160\x69\x65\x6e\164\163\72\73"; } $params = null; $sendmail_from_value = ini_get("\163\x65\x6e\144\x6d\x61\x69\x6c\x5f\146\x72\157\x6d"); if (empty($this->Sender) && !empty($sendmail_from_value)) { $this->Sender = ini_get("\x73\x65\x6e\x64\x6d\x61\151\154\137\146\x72\157\x6d"); } if (!empty($this->Sender) && static::validateAddress($this->Sender)) { if (self::isShellSafe($this->Sender)) { $params = sprintf("\x2d\146\x25\x73", $this->Sender); } $old_from = ini_get("\x73\145\156\144\x6d\141\151\154\137\x66\x72\157\155"); ini_set("\x73\x65\x6e\x64\x6d\x61\151\x6c\x5f\x66\x72\157\155", $this->Sender); } $result = false; if ($this->SingleTo && count($toArr) > 1) { foreach ($toArr as $toAddr) { $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); $addrinfo = static::parseAddresses($toAddr, true, $this->CharSet); $this->doCallback($result, array(array($addrinfo["\141\x64\144\x72\x65\163\163"], $addrinfo["\x6e\x61\x6d\x65"])), $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); } } else { $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, array()); } if (isset($old_from)) { ini_set("\x73\x65\x6e\x64\155\141\x69\154\x5f\x66\x72\x6f\x6d", $old_from); } if (!$result) { throw new Exception($this->lang("\x69\x6e\163\164\x61\x6e\x74\x69\141\164\x65"), self::STOP_CRITICAL); } return true; } public function getSMTPInstance() { if (!is_object($this->smtp)) { $this->smtp = new SMTP(); } return $this->smtp; } public function setSMTPInstance(SMTP $smtp) { $this->smtp = $smtp; return $this->smtp; } public function setSMTPXclientAttribute($name, $value) { if (!in_array($name, SMTP::$xclient_allowed_attributes)) { return false; } if (isset($this->SMTPXClient[$name]) && $value === null) { unset($this->SMTPXClient[$name]); } elseif ($value !== null) { $this->SMTPXClient[$name] = $value; } return true; } public function getSMTPXclientAttributes() { return $this->SMTPXClient; } protected function smtpSend($header, $body) { $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; $bad_rcpt = array(); if (!$this->smtpConnect($this->SMTPOptions)) { throw new Exception($this->lang("\163\155\164\160\x5f\143\157\156\x6e\145\x63\x74\137\x66\141\151\154\x65\x64"), self::STOP_CRITICAL); } if ('' === $this->Sender) { $smtp_from = $this->From; } else { $smtp_from = $this->Sender; } if (count($this->SMTPXClient)) { $this->smtp->xclient($this->SMTPXClient); } if (!$this->smtp->mail($smtp_from)) { $this->setError($this->lang("\146\162\157\155\x5f\146\141\x69\x6c\x65\144") . $smtp_from . "\x20\72\x20" . implode("\x2c", $this->smtp->getError())); throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); } $callbacks = array(); foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { foreach ($togroup as $to) { if (!$this->smtp->recipient($to[0], $this->dsn)) { $error = $this->smtp->getError(); $bad_rcpt[] = array("\164\x6f" => $to[0], "\x65\162\x72\157\x72" => $error["\x64\145\164\141\x69\x6c"]); $isSent = false; } else { $isSent = true; } $callbacks[] = array("\x69\x73\x73\145\156\x74" => $isSent, "\x74\157" => $to[0], "\x6e\x61\155\145" => $to[1]); } } if (count($this->all_recipients) > count($bad_rcpt) && !$this->smtp->data($header . $body)) { throw new Exception($this->lang("\x64\141\164\x61\137\156\157\x74\x5f\141\x63\x63\x65\x70\164\x65\x64"), self::STOP_CRITICAL); } $smtp_transaction_id = $this->smtp->getLastTransactionID(); if ($this->SMTPKeepAlive) { $this->smtp->reset(); } else { $this->smtp->quit(); $this->smtp->close(); } foreach ($callbacks as $cb) { $this->doCallback($cb["\x69\x73\163\145\156\164"], array(array($cb["\x74\x6f"], $cb["\156\141\155\145"])), array(), array(), $this->Subject, $body, $this->From, array("\163\x6d\164\x70\137\164\x72\x61\x6e\x73\141\143\164\x69\x6f\156\x5f\151\144" => $smtp_transaction_id)); } if (count($bad_rcpt) > 0) { $errstr = ''; foreach ($bad_rcpt as $bad) { $errstr .= $bad["\x74\x6f"] . "\x3a\x20" . $bad["\x65\x72\162\x6f\x72"]; } throw new Exception($this->lang("\x72\145\143\151\x70\151\145\156\164\x73\x5f\146\141\x69\x6c\x65\144") . $errstr, self::STOP_CONTINUE); } return true; } public function smtpConnect($options = null) { if (null === $this->smtp) { $this->smtp = $this->getSMTPInstance(); } if (null === $options) { $options = $this->SMTPOptions; } if ($this->smtp->connected()) { return true; } $this->smtp->setTimeout($this->Timeout); $this->smtp->setDebugLevel($this->SMTPDebug); $this->smtp->setDebugOutput($this->Debugoutput); $this->smtp->setVerp($this->do_verp); if ($this->Host === null) { $this->Host = "\154\x6f\143\x61\154\150\157\163\x74"; } $hosts = explode("\x3b", $this->Host); $lastexception = null; foreach ($hosts as $hostentry) { $hostinfo = array(); if (!preg_match("\x2f\136\50\x3f\72\x28\163\x73\x6c\174\164\154\x73\51\72\134\x2f\134\57\51\x3f\x28\56\x2b\77\x29\50\77\x3a\x3a\x28\x5c\x64\x2b\x29\x29\x3f\x24\57", trim($hostentry), $hostinfo)) { $this->edebug($this->lang("\151\x6e\x76\141\154\151\x64\137\150\x6f\x73\164\145\156\x74\x72\171") . "\x20" . trim($hostentry)); continue; } if (!static::isValidHost($hostinfo[2])) { $this->edebug($this->lang("\x69\156\166\141\x6c\151\144\137\150\157\163\164") . "\40" . $hostinfo[2]); continue; } $prefix = ''; $secure = $this->SMTPSecure; $tls = static::ENCRYPTION_STARTTLS === $this->SMTPSecure; if ("\163\163\x6c" === $hostinfo[1] || '' === $hostinfo[1] && static::ENCRYPTION_SMTPS === $this->SMTPSecure) { $prefix = "\x73\163\154\x3a\57\x2f"; $tls = false; $secure = static::ENCRYPTION_SMTPS; } elseif ("\164\154\163" === $hostinfo[1]) { $tls = true; $secure = static::ENCRYPTION_STARTTLS; } $sslext = defined("\x4f\x50\x45\116\x53\123\114\x5f\x41\x4c\x47\117\x5f\123\110\101\62\x35\x36"); if (static::ENCRYPTION_STARTTLS === $secure || static::ENCRYPTION_SMTPS === $secure) { if (!$sslext) { throw new Exception($this->lang("\x65\170\164\x65\156\163\x69\157\x6e\137\x6d\x69\x73\x73\151\x6e\x67") . "\x6f\160\145\156\x73\x73\x6c", self::STOP_CRITICAL); } } $host = $hostinfo[2]; $port = $this->Port; if (array_key_exists(3, $hostinfo) && is_numeric($hostinfo[3]) && $hostinfo[3] > 0 && $hostinfo[3] < 65536) { $port = (int) $hostinfo[3]; } if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { try { if ($this->Helo) { $hello = $this->Helo; } else { $hello = $this->serverHostname(); } $this->smtp->hello($hello); if ($this->SMTPAutoTLS && $this->Host !== "\x6c\x6f\x63\x61\x6c\x68\157\163\x74" && $sslext && $secure !== "\x73\x73\x6c" && $this->smtp->getServerExt("\x53\x54\x41\122\x54\x54\114\x53")) { $tls = true; } if ($tls) { if (!$this->smtp->startTLS()) { $message = $this->getSmtpErrorMessage("\143\x6f\156\156\x65\x63\x74\137\150\157\x73\164"); throw new Exception($message); } $this->smtp->hello($hello); } if ($this->SMTPAuth && !$this->smtp->authenticate($this->Username, $this->Password, $this->AuthType, $this->oauth)) { throw new Exception($this->lang("\x61\165\164\150\145\x6e\164\x69\143\x61\164\145")); } return true; } catch (Exception $exc) { $lastexception = $exc; $this->edebug($exc->getMessage()); $this->smtp->quit(); } } } $this->smtp->close(); if ($this->exceptions && null !== $lastexception) { throw $lastexception; } if ($this->exceptions) { $message = $this->getSmtpErrorMessage("\143\x6f\156\156\145\x63\x74\x5f\x68\x6f\163\164"); throw new Exception($message); } return false; } public function smtpClose() { if (null !== $this->smtp && $this->smtp->connected()) { $this->smtp->quit(); $this->smtp->close(); } } public function setLanguage($langcode = "\x65\156", $lang_path = '') { $renamed_langcodes = array("\x62\162" => "\x70\x74\x5f\x62\x72", "\143\x7a" => "\x63\x73", "\x64\x6b" => "\144\x61", "\156\157" => "\156\x62", "\163\x65" => "\x73\166", "\162\163" => "\163\x72", "\x74\147" => "\x74\x6c", "\x61\x6d" => "\x68\171"); if (array_key_exists($langcode, $renamed_langcodes)) { $langcode = $renamed_langcodes[$langcode]; } $PHPMAILER_LANG = array("\x61\165\164\x68\145\x6e\164\x69\143\x61\x74\145" => "\123\x4d\x54\120\x20\x45\x72\x72\157\162\72\40\103\x6f\x75\154\144\40\x6e\x6f\x74\40\141\165\164\x68\x65\156\164\x69\143\x61\164\x65\56", "\142\x75\x67\x67\171\x5f\x70\x68\x70" => "\x59\x6f\x75\x72\40\x76\145\x72\x73\x69\x6f\x6e\40\157\x66\40\x50\110\120\40\x69\x73\40\x61\x66\146\x65\x63\164\x65\x64\x20\x62\x79\x20\141\40\142\165\x67\x20\164\x68\x61\x74\x20\x6d\x61\x79\40\162\145\x73\x75\154\164\40\x69\x6e\40\143\157\x72\162\x75\x70\x74\x65\x64\x20\155\145\163\x73\141\147\x65\x73\x2e" . "\40\x54\157\x20\146\x69\170\40\x69\x74\54\40\163\x77\151\164\143\x68\40\164\x6f\x20\x73\145\x6e\x64\151\x6e\x67\x20\165\x73\x69\x6e\147\x20\x53\115\x54\120\x2c\x20\x64\151\x73\141\x62\154\x65\x20\x74\150\145\x20\155\x61\x69\154\56\x61\144\144\137\x78\x5f\x68\145\141\144\145\x72\40\x6f\x70\164\x69\x6f\156\40\x69\156" . "\40\171\157\x75\162\40\160\x68\160\56\x69\156\x69\54\x20\x73\167\x69\164\143\x68\40\x74\x6f\x20\x4d\141\x63\117\x53\40\157\x72\x20\114\151\156\165\170\54\40\157\x72\x20\x75\x70\x67\x72\x61\x64\145\x20\x79\x6f\165\x72\40\x50\110\x50\40\x74\157\x20\x76\145\162\163\151\x6f\156\x20\x37\x2e\60\x2e\x31\x37\53\40\x6f\162\x20\x37\x2e\61\56\x33\x2b\x2e", "\143\x6f\156\x6e\x65\143\164\x5f\150\x6f\x73\164" => "\x53\115\124\x50\x20\x45\x72\162\x6f\162\72\x20\103\x6f\165\154\x64\40\156\157\164\x20\x63\157\156\x6e\145\x63\x74\x20\164\x6f\x20\x53\115\x54\120\40\x68\x6f\163\x74\56", "\x64\x61\x74\x61\137\x6e\x6f\x74\137\x61\x63\x63\145\160\x74\x65\x64" => "\x53\115\124\120\40\105\x72\162\157\x72\72\40\x64\x61\x74\141\x20\156\x6f\x74\x20\x61\143\143\145\160\164\145\144\56", "\x65\155\160\164\171\137\x6d\x65\163\x73\x61\x67\x65" => "\115\x65\163\x73\x61\x67\x65\x20\142\157\x64\171\40\145\x6d\160\x74\x79", "\145\156\x63\x6f\x64\x69\x6e\x67" => "\125\156\153\x6e\x6f\167\156\x20\145\156\x63\157\x64\151\156\x67\72\x20", "\145\170\x65\x63\165\x74\x65" => "\x43\x6f\165\x6c\x64\x20\156\x6f\164\x20\x65\x78\x65\x63\x75\x74\145\72\x20", "\x65\170\x74\x65\x6e\163\151\x6f\156\137\155\x69\163\x73\x69\x6e\147" => "\105\x78\x74\145\156\163\151\x6f\x6e\40\x6d\x69\163\x73\151\x6e\147\72\40", "\146\x69\x6c\145\137\141\x63\143\x65\x73\x73" => "\103\x6f\165\154\x64\x20\156\157\x74\40\141\x63\x63\145\x73\163\40\x66\151\154\145\72\x20", "\x66\x69\154\145\137\x6f\160\145\x6e" => "\106\151\x6c\145\x20\105\x72\162\157\x72\x3a\40\x43\x6f\165\x6c\x64\x20\156\157\x74\x20\x6f\x70\x65\x6e\x20\146\x69\x6c\x65\x3a\40", "\146\x72\157\x6d\x5f\x66\141\151\154\x65\x64" => "\x54\x68\145\x20\146\x6f\154\x6c\157\x77\x69\156\147\x20\x46\x72\157\x6d\x20\141\144\x64\162\145\163\163\40\146\141\151\x6c\x65\x64\72\40", "\x69\x6e\163\164\141\156\x74\151\x61\x74\145" => "\103\x6f\165\x6c\x64\40\x6e\157\164\x20\x69\x6e\x73\x74\x61\156\x74\151\x61\x74\x65\40\155\141\151\x6c\40\x66\165\x6e\x63\164\151\x6f\156\56", "\x69\x6e\166\141\x6c\151\144\137\141\x64\144\x72\145\x73\163" => "\x49\x6e\x76\141\154\151\x64\x20\141\x64\144\x72\x65\x73\163\x3a\x20", "\151\156\x76\x61\154\151\x64\x5f\x68\x65\x61\144\145\x72" => "\x49\x6e\166\141\154\151\x64\x20\x68\145\x61\144\145\x72\40\x6e\141\155\x65\x20\157\162\40\x76\x61\154\165\x65", "\151\156\x76\x61\x6c\x69\144\137\x68\157\x73\x74\145\156\x74\162\x79" => "\111\156\166\141\x6c\x69\x64\x20\150\x6f\x73\x74\145\x6e\164\162\x79\72\40", "\151\156\166\x61\154\151\144\x5f\150\157\163\x74" => "\x49\156\x76\x61\154\x69\x64\x20\x68\157\163\x74\72\x20", "\x6d\141\x69\154\x65\x72\137\x6e\157\x74\x5f\163\165\160\x70\x6f\x72\x74\x65\144" => "\x20\x6d\x61\x69\x6c\x65\162\40\x69\163\x20\156\x6f\164\x20\163\x75\160\160\157\162\x74\145\x64\x2e", "\160\x72\157\166\x69\x64\x65\137\x61\144\144\x72\145\x73\x73" => "\131\157\x75\x20\x6d\165\x73\164\40\x70\x72\x6f\166\x69\144\x65\40\141\164\40\154\145\x61\163\x74\x20\157\156\145\40\x72\145\143\151\x70\151\x65\x6e\x74\x20\145\x6d\x61\x69\x6c\40\x61\144\144\162\x65\163\x73\56", "\162\145\143\151\160\151\145\156\164\163\x5f\x66\141\151\x6c\145\x64" => "\123\x4d\x54\x50\40\x45\x72\x72\157\162\72\x20\x54\150\x65\40\146\157\x6c\154\157\x77\151\x6e\x67\x20\x72\x65\x63\x69\x70\x69\145\156\164\x73\x20\x66\x61\x69\154\145\144\72\40", "\163\151\147\x6e\x69\156\x67" => "\123\x69\147\x6e\x69\x6e\x67\x20\105\162\162\157\162\72\40", "\x73\155\x74\160\x5f\143\157\x64\x65" => "\x53\115\x54\120\40\x63\157\144\x65\x3a\40", "\x73\x6d\164\160\137\143\x6f\x64\145\137\145\170" => "\101\x64\144\x69\x74\x69\157\156\x61\154\x20\x53\x4d\x54\x50\x20\x69\156\x66\157\72\40", "\x73\x6d\164\x70\x5f\x63\x6f\x6e\x6e\145\x63\164\137\146\141\x69\x6c\x65\x64" => "\123\x4d\124\120\x20\x63\157\x6e\156\145\143\x74\50\x29\x20\146\x61\151\x6c\145\144\x2e", "\163\x6d\x74\160\x5f\x64\x65\164\x61\151\154" => "\104\x65\x74\141\151\x6c\x3a\40", "\x73\155\164\160\x5f\145\x72\162\x6f\x72" => "\123\115\124\120\x20\163\145\x72\x76\145\x72\x20\145\162\x72\157\x72\72\40", "\x76\x61\162\151\141\142\154\x65\x5f\163\145\x74" => "\103\x61\156\156\157\164\40\163\x65\164\x20\157\162\40\x72\x65\x73\x65\x74\x20\x76\x61\162\x69\141\x62\x6c\145\x3a\x20"); if (empty($lang_path)) { $lang_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . "\154\141\x6e\x67\165\x61\147\145" . DIRECTORY_SEPARATOR; } $foundlang = true; $langcode = strtolower($langcode); if (!preg_match("\57\x5e\50\77\120\74\154\141\x6e\x67\76\x5b\x61\x2d\172\x5d\173\62\x7d\x29\50\x3f\x50\x3c\x73\143\x72\x69\160\164\x3e\137\x5b\141\55\172\135\x7b\64\x7d\51\x3f\x28\77\x50\x3c\x63\x6f\x75\156\x74\x72\x79\x3e\x5f\133\x61\55\x7a\135\173\62\175\x29\77\44\57", $langcode, $matches) && $langcode !== "\x65\156") { $foundlang = false; $langcode = "\145\156"; } if ("\145\x6e" !== $langcode) { $langcodes = array(); if (!empty($matches["\163\x63\x72\151\x70\x74"]) && !empty($matches["\x63\x6f\x75\156\164\162\171"])) { $langcodes[] = $matches["\x6c\x61\x6e\x67"] . $matches["\x73\143\x72\151\x70\164"] . $matches["\x63\157\165\x6e\x74\x72\x79"]; } if (!empty($matches["\143\157\165\x6e\164\162\171"])) { $langcodes[] = $matches["\x6c\141\156\147"] . $matches["\143\x6f\165\156\x74\162\171"]; } if (!empty($matches["\x73\143\162\x69\160\164"])) { $langcodes[] = $matches["\154\x61\x6e\147"] . $matches["\x73\143\162\151\160\x74"]; } $langcodes[] = $matches["\154\141\156\x67"]; $foundFile = false; foreach ($langcodes as $code) { $lang_file = $lang_path . "\160\x68\160\155\141\x69\154\145\162\x2e\x6c\x61\x6e\147\x2d" . $code . "\56\160\x68\160"; if (static::fileIsAccessible($lang_file)) { $foundFile = true; break; } } if ($foundFile === false) { $foundlang = false; } else { $lines = file($lang_file); foreach ($lines as $line) { $matches = array(); if (preg_match("\57\136\134\x24\x50\x48\x50\115\x41\x49\x4c\x45\122\137\x4c\x41\116\x47\x5c\x5b\47\50\x5b\x61\x2d\x7a\x5c\x64\137\135\x2b\x29\x27\134\x5d\134\163\x2a\75\134\163\x2a\50\133\42\47\135\x29\50\56\53\51\x2a\x3f\134\x32\73\57", $line, $matches) && array_key_exists($matches[1], $PHPMAILER_LANG)) { $PHPMAILER_LANG[$matches[1]] = (string) $matches[3]; } } } } $this->language = $PHPMAILER_LANG; return $foundlang; } public function getTranslations() { if (empty($this->language)) { $this->setLanguage(); } return $this->language; } public function addrAppend($type, $addr) { $addresses = array(); foreach ($addr as $address) { $addresses[] = $this->addrFormat($address); } return $type . "\72\x20" . implode("\x2c\x20", $addresses) . static::$LE; } public function addrFormat($addr) { if (!isset($addr[1]) || $addr[1] === '') { return $this->secureHeader($addr[0]); } return $this->encodeHeader($this->secureHeader($addr[1]), "\160\150\162\x61\163\x65") . "\40\74" . $this->secureHeader($addr[0]) . "\x3e"; } public function wrapText($message, $length, $qp_mode = false) { if ($qp_mode) { $soft_break = sprintf("\x20\75\x25\163", static::$LE); } else { $soft_break = static::$LE; } $is_utf8 = static::CHARSET_UTF8 === strtolower($this->CharSet); $lelen = strlen(static::$LE); $crlflen = strlen(static::$LE); $message = static::normalizeBreaks($message); if (substr($message, -$lelen) === static::$LE) { $message = substr($message, 0, -$lelen); } $lines = explode(static::$LE, $message); $message = ''; foreach ($lines as $line) { $words = explode("\x20", $line); $buf = ''; $firstword = true; foreach ($words as $word) { if ($qp_mode && strlen($word) > $length) { $space_left = $length - strlen($buf) - $crlflen; if (!$firstword) { if ($space_left > 20) { $len = $space_left; if ($is_utf8) { $len = $this->utf8CharBoundary($word, $len); } elseif ("\x3d" === substr($word, $len - 1, 1)) { --$len; } elseif ("\x3d" === substr($word, $len - 2, 1)) { $len -= 2; } $part = substr($word, 0, $len); $word = substr($word, $len); $buf .= "\40" . $part; $message .= $buf . sprintf("\75\x25\163", static::$LE); } else { $message .= $buf . $soft_break; } $buf = ''; } while ($word !== '') { if ($length <= 0) { break; } $len = $length; if ($is_utf8) { $len = $this->utf8CharBoundary($word, $len); } elseif ("\x3d" === substr($word, $len - 1, 1)) { --$len; } elseif ("\75" === substr($word, $len - 2, 1)) { $len -= 2; } $part = substr($word, 0, $len); $word = (string) substr($word, $len); if ($word !== '') { $message .= $part . sprintf("\75\45\163", static::$LE); } else { $buf = $part; } } } else { $buf_o = $buf; if (!$firstword) { $buf .= "\x20"; } $buf .= $word; if ('' !== $buf_o && strlen($buf) > $length) { $message .= $buf_o . $soft_break; $buf = $word; } } $firstword = false; } $message .= $buf . static::$LE; } return $message; } public function utf8CharBoundary($encodedText, $maxLength) { $foundSplitPos = false; $lookBack = 3; while (!$foundSplitPos) { $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); $encodedCharPos = strpos($lastChunk, "\75"); if (false !== $encodedCharPos) { $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); $dec = hexdec($hex); if ($dec < 128) { if ($encodedCharPos > 0) { $maxLength -= $lookBack - $encodedCharPos; } $foundSplitPos = true; } elseif ($dec >= 192) { $maxLength -= $lookBack - $encodedCharPos; $foundSplitPos = true; } elseif ($dec < 192) { $lookBack += 3; } } else { $foundSplitPos = true; } } return $maxLength; } public function setWordWrap() { if ($this->WordWrap < 1) { return; } switch ($this->message_type) { case "\141\154\164": case "\141\154\x74\x5f\x69\x6e\x6c\151\156\x65": case "\x61\x6c\x74\x5f\141\164\164\141\143\x68": case "\141\154\164\x5f\151\x6e\x6c\x69\x6e\145\x5f\x61\164\x74\141\143\150": $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap); break; default: $this->Body = $this->wrapText($this->Body, $this->WordWrap); break; } } public function createHeader() { $result = ''; $result .= $this->headerLine("\x44\141\x74\x65", '' === $this->MessageDate ? self::rfcDate() : $this->MessageDate); if ("\x6d\x61\151\154" !== $this->Mailer) { if ($this->SingleTo) { foreach ($this->to as $toaddr) { $this->SingleToArray[] = $this->addrFormat($toaddr); } } elseif (count($this->to) > 0) { $result .= $this->addrAppend("\124\157", $this->to); } elseif (count($this->cc) === 0) { $result .= $this->headerLine("\124\x6f", "\x75\x6e\144\151\163\143\x6c\157\163\145\144\x2d\x72\x65\x63\151\x70\x69\x65\156\164\163\x3a\73"); } } $result .= $this->addrAppend("\x46\x72\x6f\155", array(array(trim($this->From), $this->FromName))); if (count($this->cc) > 0) { $result .= $this->addrAppend("\x43\x63", $this->cc); } if (("\x73\145\156\x64\155\x61\x69\x6c" === $this->Mailer || "\161\x6d\x61\x69\x6c" === $this->Mailer || "\155\141\x69\x6c" === $this->Mailer) && count($this->bcc) > 0) { $result .= $this->addrAppend("\102\143\143", $this->bcc); } if (count($this->ReplyTo) > 0) { $result .= $this->addrAppend("\x52\145\x70\x6c\171\x2d\x54\x6f", $this->ReplyTo); } if ("\x6d\x61\151\x6c" !== $this->Mailer) { $result .= $this->headerLine("\123\x75\142\152\145\143\x74", $this->encodeHeader($this->secureHeader($this->Subject))); } if ('' !== $this->MessageID && preg_match("\x2f\136\74\x28\x28\50\x5b\x61\55\172\x5c\x64\x21\43\44\x25\x26\47\52\x2b\x5c\57\75\x3f\x5e\x5f\x60\173\x7c\x7d\176\x2d\x5d\x2b\50\134\56\133\141\x2d\x7a\x5c\144\41\x23\44\x25\x26\47\52\53\134\57\x3d\x3f\x5e\x5f\140\x7b\174\x7d\176\x2d\135\53\51\x2a\51" . "\x7c\50\x22\x28\x28\133\134\170\60\x31\x2d\x5c\170\x30\70\x5c\x78\60\102\x5c\170\x30\x43\x5c\x78\60\105\x2d\134\x78\x31\x46\x5c\170\67\x46\x5d\174\133\x5c\x78\62\x31\x5c\x78\62\63\x2d\134\x78\65\x42\x5c\170\65\104\x2d\x5c\170\x37\105\135\x29" . "\x7c\x28\x5c\133\x5c\170\60\61\55\x5c\170\x30\x39\x5c\170\x30\102\134\x78\60\103\x5c\x78\x30\x45\55\x5c\x78\x37\x46\x5d\51\x29\52\42\51\x29\100\50\50\x5b\141\x2d\172\134\144\41\x23\44\45\x26\47\x2a\x2b\x5c\57\x3d\x3f\136\137\x60\x7b\x7c\175\x7e\x2d\x5d\x2b" . "\50\x5c\56\x5b\141\55\172\x5c\x64\x21\x23\x24\x25\x26\x27\x2a\x2b\x5c\57\75\77\x5e\137\140\x7b\x7c\175\176\55\x5d\x2b\51\52\51\174\50\x5c\133\50\50\x5b\x5c\x78\x30\x31\55\x5c\x78\x30\x38\134\x78\60\102\x5c\170\60\x43\134\x78\60\x45\55\x5c\170\x31\106\x5c\170\67\x46\x5d" . "\x7c\x5b\x5c\x78\62\x31\x2d\x5c\170\x35\x41\x5c\x78\x35\x45\x2d\134\170\x37\105\x5d\51\174\50\134\x5b\134\x78\60\61\x2d\x5c\170\60\x39\x5c\170\x30\102\134\x78\x30\x43\134\170\x30\x45\x2d\x5c\170\x37\x46\x5d\51\51\x2a\134\135\51\51\x29\76\x24\57\x44\x69", $this->MessageID)) { $this->lastMessageID = $this->MessageID; } else { $this->lastMessageID = sprintf("\x3c\45\x73\x40\45\163\76", $this->uniqueid, $this->serverHostname()); } $result .= $this->headerLine("\x4d\x65\x73\x73\x61\x67\x65\55\111\x44", $this->lastMessageID); if (null !== $this->Priority) { $result .= $this->headerLine("\x58\55\120\x72\x69\x6f\x72\151\x74\171", $this->Priority); } if ('' === $this->XMailer) { $result .= $this->headerLine("\130\x2d\115\x61\x69\x6c\x65\x72", "\120\110\x50\x4d\x61\x69\154\x65\x72\x20" . self::VERSION . "\40\x28\150\x74\x74\x70\163\x3a\57\57\147\x69\164\x68\165\x62\56\143\x6f\x6d\x2f\120\110\x50\115\x61\x69\x6c\145\x72\57\120\x48\120\x4d\x61\x69\x6c\x65\162\x29"); } elseif (is_string($this->XMailer) && trim($this->XMailer) !== '') { $result .= $this->headerLine("\130\x2d\115\x61\x69\x6c\145\162", trim($this->XMailer)); } if ('' !== $this->ConfirmReadingTo) { $result .= $this->headerLine("\x44\151\163\x70\157\x73\x69\164\151\x6f\156\55\x4e\x6f\x74\x69\146\151\x63\x61\164\x69\x6f\156\x2d\124\157", "\x3c" . $this->ConfirmReadingTo . "\x3e"); } foreach ($this->CustomHeader as $header) { $result .= $this->headerLine(trim($header[0]), $this->encodeHeader(trim($header[1]))); } if (!$this->sign_key_file) { $result .= $this->headerLine("\x4d\111\x4d\105\x2d\126\x65\162\163\x69\x6f\156", "\61\56\x30"); $result .= $this->getMailMIME(); } return $result; } public function getMailMIME() { $result = ''; $ismultipart = true; switch ($this->message_type) { case "\151\x6e\154\x69\156\x65": $result .= $this->headerLine("\x43\x6f\x6e\x74\x65\x6e\164\x2d\x54\171\x70\x65", static::CONTENT_TYPE_MULTIPART_RELATED . "\x3b"); $result .= $this->textLine("\x20\142\x6f\x75\x6e\x64\x61\x72\171\75\x22" . $this->boundary[1] . "\x22"); break; case "\x61\x74\164\x61\143\x68": case "\151\156\154\151\x6e\145\x5f\141\x74\x74\x61\x63\x68": case "\x61\154\164\x5f\x61\164\x74\141\x63\150": case "\141\154\164\137\151\x6e\154\x69\156\145\137\x61\164\164\141\143\150": $result .= $this->headerLine("\x43\x6f\x6e\x74\x65\156\x74\x2d\124\x79\160\x65", static::CONTENT_TYPE_MULTIPART_MIXED . "\73"); $result .= $this->textLine("\40\x62\x6f\165\156\x64\x61\x72\171\75\x22" . $this->boundary[1] . "\x22"); break; case "\141\154\164": case "\x61\154\164\x5f\151\156\x6c\x69\156\x65": $result .= $this->headerLine("\x43\x6f\156\164\x65\156\x74\x2d\124\x79\160\x65", static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . "\x3b"); $result .= $this->textLine("\40\x62\x6f\x75\156\144\141\162\x79\x3d\42" . $this->boundary[1] . "\x22"); break; default: $result .= $this->textLine("\103\x6f\156\x74\x65\x6e\164\x2d\124\x79\x70\x65\x3a\40" . $this->ContentType . "\x3b\40\x63\x68\x61\x72\x73\x65\x74\75" . $this->CharSet); $ismultipart = false; break; } if (static::ENCODING_7BIT !== $this->Encoding) { if ($ismultipart) { if (static::ENCODING_8BIT === $this->Encoding) { $result .= $this->headerLine("\103\x6f\x6e\x74\145\156\164\x2d\124\x72\141\156\163\x66\145\162\55\105\156\x63\157\x64\151\x6e\147", static::ENCODING_8BIT); } } else { $result .= $this->headerLine("\103\x6f\156\x74\145\156\164\55\124\x72\141\x6e\163\146\145\x72\55\105\156\143\157\144\x69\x6e\x67", $this->Encoding); } } return $result; } public function getSentMIMEMessage() { return static::stripTrailingWSP($this->MIMEHeader . $this->mailHeader) . static::$LE . static::$LE . $this->MIMEBody; } protected function generateId() { $len = 32; $bytes = ''; if (function_exists("\x72\141\x6e\144\x6f\x6d\137\x62\171\164\x65\x73")) { try { $bytes = random_bytes($len); } catch (\Exception $e) { } } elseif (function_exists("\x6f\x70\x65\156\163\x73\x6c\x5f\162\x61\156\x64\x6f\155\137\160\x73\x65\165\144\x6f\x5f\x62\171\164\145\x73")) { $bytes = openssl_random_pseudo_bytes($len); } if ($bytes === '') { $bytes = hash("\163\150\x61\x32\x35\66", uniqid((string) mt_rand(), true), true); } return str_replace(array("\x3d", "\53", "\x2f"), '', base64_encode(hash("\x73\x68\141\x32\x35\x36", $bytes, true))); } public function createBody() { $body = ''; $this->setBoundaries(); if ($this->sign_key_file) { $body .= $this->getMailMIME() . static::$LE; } $this->setWordWrap(); $bodyEncoding = $this->Encoding; $bodyCharSet = $this->CharSet; if (static::ENCODING_8BIT === $bodyEncoding && !$this->has8bitChars($this->Body)) { $bodyEncoding = static::ENCODING_7BIT; $bodyCharSet = static::CHARSET_ASCII; } if (static::ENCODING_BASE64 !== $this->Encoding && static::hasLineLongerThanMax($this->Body)) { $bodyEncoding = static::ENCODING_QUOTED_PRINTABLE; } $altBodyEncoding = $this->Encoding; $altBodyCharSet = $this->CharSet; if (static::ENCODING_8BIT === $altBodyEncoding && !$this->has8bitChars($this->AltBody)) { $altBodyEncoding = static::ENCODING_7BIT; $altBodyCharSet = static::CHARSET_ASCII; } if (static::ENCODING_BASE64 !== $altBodyEncoding && static::hasLineLongerThanMax($this->AltBody)) { $altBodyEncoding = static::ENCODING_QUOTED_PRINTABLE; } $mimepre = ''; switch ($this->message_type) { case "\x69\156\x6c\x69\x6e\x65": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("\x69\156\x6c\x69\x6e\145", $this->boundary[1]); break; case "\141\164\164\x61\x63\x68": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("\141\164\164\141\x63\x68\x6d\x65\x6e\x74", $this->boundary[1]); break; case "\151\x6e\154\151\x6e\145\137\141\x74\x74\141\x63\x68": $body .= $mimepre; $body .= $this->textLine("\55\x2d" . $this->boundary[1]); $body .= $this->headerLine("\x43\x6f\156\164\145\x6e\x74\55\x54\171\x70\x65", static::CONTENT_TYPE_MULTIPART_RELATED . "\x3b"); $body .= $this->textLine("\40\142\157\165\x6e\144\x61\x72\x79\75\x22" . $this->boundary[2] . "\x22\x3b"); $body .= $this->textLine("\x20\x74\171\x70\x65\75\42" . static::CONTENT_TYPE_TEXT_HTML . "\42"); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("\x69\x6e\154\x69\x6e\x65", $this->boundary[2]); $body .= static::$LE; $body .= $this->attachAll("\x61\x74\x74\141\143\x68\155\x65\156\x74", $this->boundary[1]); break; case "\x61\x6c\x74": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; if (!empty($this->Ical)) { $method = static::ICAL_METHOD_REQUEST; foreach (static::$IcalMethods as $imethod) { if (stripos($this->Ical, "\115\105\124\110\x4f\x44\x3a" . $imethod) !== false) { $method = $imethod; break; } } $body .= $this->getBoundary($this->boundary[1], '', static::CONTENT_TYPE_TEXT_CALENDAR . "\73\x20\x6d\x65\164\x68\x6f\144\75" . $method, ''); $body .= $this->encodeString($this->Ical, $this->Encoding); $body .= static::$LE; } $body .= $this->endBoundary($this->boundary[1]); break; case "\141\x6c\164\x5f\151\x6e\154\x69\156\x65": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->textLine("\55\x2d" . $this->boundary[1]); $body .= $this->headerLine("\x43\x6f\x6e\x74\145\156\x74\x2d\x54\x79\160\x65", static::CONTENT_TYPE_MULTIPART_RELATED . "\x3b"); $body .= $this->textLine("\x20\142\157\165\156\144\x61\162\x79\x3d\x22" . $this->boundary[2] . "\42\x3b"); $body .= $this->textLine("\x20\164\171\x70\145\75\42" . static::CONTENT_TYPE_TEXT_HTML . "\42"); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("\x69\x6e\x6c\x69\x6e\145", $this->boundary[2]); $body .= static::$LE; $body .= $this->endBoundary($this->boundary[1]); break; case "\141\154\x74\137\x61\164\x74\141\143\x68": $body .= $mimepre; $body .= $this->textLine("\55\x2d" . $this->boundary[1]); $body .= $this->headerLine("\x43\157\156\x74\145\x6e\x74\x2d\124\x79\x70\x65", static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . "\x3b"); $body .= $this->textLine("\x20\142\157\165\x6e\144\x61\x72\171\x3d\x22" . $this->boundary[2] . "\42"); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; if (!empty($this->Ical)) { $method = static::ICAL_METHOD_REQUEST; foreach (static::$IcalMethods as $imethod) { if (stripos($this->Ical, "\x4d\x45\124\x48\x4f\104\x3a" . $imethod) !== false) { $method = $imethod; break; } } $body .= $this->getBoundary($this->boundary[2], '', static::CONTENT_TYPE_TEXT_CALENDAR . "\73\40\x6d\145\x74\150\157\x64\x3d" . $method, ''); $body .= $this->encodeString($this->Ical, $this->Encoding); } $body .= $this->endBoundary($this->boundary[2]); $body .= static::$LE; $body .= $this->attachAll("\x61\x74\164\x61\143\150\155\145\x6e\x74", $this->boundary[1]); break; case "\x61\154\164\x5f\151\x6e\154\x69\156\145\x5f\141\164\x74\x61\143\150": $body .= $mimepre; $body .= $this->textLine("\x2d\55" . $this->boundary[1]); $body .= $this->headerLine("\x43\157\156\164\x65\156\164\x2d\124\x79\x70\145", static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . "\73"); $body .= $this->textLine("\40\x62\157\x75\156\144\141\x72\x79\x3d\x22" . $this->boundary[2] . "\x22"); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->textLine("\x2d\x2d" . $this->boundary[2]); $body .= $this->headerLine("\x43\x6f\x6e\x74\x65\x6e\164\55\x54\171\160\x65", static::CONTENT_TYPE_MULTIPART_RELATED . "\x3b"); $body .= $this->textLine("\x20\x62\x6f\x75\156\144\141\162\171\75\42" . $this->boundary[3] . "\x22\73"); $body .= $this->textLine("\x20\x74\171\x70\x65\75\42" . static::CONTENT_TYPE_TEXT_HTML . "\x22"); $body .= static::$LE; $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll("\151\156\154\151\x6e\x65", $this->boundary[3]); $body .= static::$LE; $body .= $this->endBoundary($this->boundary[2]); $body .= static::$LE; $body .= $this->attachAll("\141\164\x74\x61\143\x68\155\145\x6e\x74", $this->boundary[1]); break; default: $this->Encoding = $bodyEncoding; $body .= $this->encodeString($this->Body, $this->Encoding); break; } if ($this->isError()) { $body = ''; if ($this->exceptions) { throw new Exception($this->lang("\145\x6d\x70\x74\x79\137\x6d\x65\163\x73\141\x67\145"), self::STOP_CRITICAL); } } elseif ($this->sign_key_file) { try { if (!defined("\120\x4b\x43\123\67\x5f\124\x45\x58\x54")) { throw new Exception($this->lang("\x65\170\x74\145\156\163\x69\157\x6e\137\x6d\151\x73\x73\x69\156\x67") . "\x6f\x70\x65\x6e\x73\x73\x6c"); } $file = tempnam(sys_get_temp_dir(), "\163\162\143\x73\x69\147\156"); $signed = tempnam(sys_get_temp_dir(), "\155\141\151\x6c\x73\x69\147\x6e"); file_put_contents($file, $body); if (empty($this->sign_extracerts_file)) { $sign = @openssl_pkcs7_sign($file, $signed, "\146\x69\154\145\x3a\57\57" . realpath($this->sign_cert_file), array("\146\151\x6c\145\72\x2f\57" . realpath($this->sign_key_file), $this->sign_key_pass), array()); } else { $sign = @openssl_pkcs7_sign($file, $signed, "\146\151\x6c\145\72\x2f\57" . realpath($this->sign_cert_file), array("\146\151\154\x65\72\57\57" . realpath($this->sign_key_file), $this->sign_key_pass), array(), PKCS7_DETACHED, $this->sign_extracerts_file); } @unlink($file); if ($sign) { $body = file_get_contents($signed); @unlink($signed); $parts = explode("\xa\12", $body, 2); $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE; $body = $parts[1]; } else { @unlink($signed); throw new Exception($this->lang("\163\151\147\156\151\x6e\x67") . openssl_error_string()); } } catch (Exception $exc) { $body = ''; if ($this->exceptions) { throw $exc; } } } return $body; } public function getBoundaries() { if (empty($this->boundary)) { $this->setBoundaries(); } return $this->boundary; } protected function getBoundary($boundary, $charSet, $contentType, $encoding) { $result = ''; if ('' === $charSet) { $charSet = $this->CharSet; } if ('' === $contentType) { $contentType = $this->ContentType; } if ('' === $encoding) { $encoding = $this->Encoding; } $result .= $this->textLine("\x2d\55" . $boundary); $result .= sprintf("\103\157\156\164\145\156\x74\x2d\x54\171\x70\x65\x3a\x20\45\x73\73\40\143\x68\x61\162\163\145\x74\75\45\x73", $contentType, $charSet); $result .= static::$LE; if (static::ENCODING_7BIT !== $encoding) { $result .= $this->headerLine("\103\x6f\156\x74\145\156\x74\55\124\x72\141\x6e\x73\x66\x65\162\55\x45\x6e\143\x6f\x64\x69\156\x67", $encoding); } $result .= static::$LE; return $result; } protected function endBoundary($boundary) { return static::$LE . "\55\x2d" . $boundary . "\55\55" . static::$LE; } protected function setMessageType() { $type = array(); if ($this->alternativeExists()) { $type[] = "\x61\x6c\164"; } if ($this->inlineImageExists()) { $type[] = "\x69\156\x6c\151\x6e\x65"; } if ($this->attachmentExists()) { $type[] = "\141\x74\x74\141\143\x68"; } $this->message_type = implode("\x5f", $type); if ('' === $this->message_type) { $this->message_type = "\160\154\x61\151\156"; } } public function headerLine($name, $value) { return $name . "\72\40" . $value . static::$LE; } public function textLine($value) { return $value . static::$LE; } public function addAttachment($path, $name = '', $encoding = self::ENCODING_BASE64, $type = '', $disposition = "\141\x74\x74\141\143\150\x6d\x65\156\x74") { try { if (!static::fileIsAccessible($path)) { throw new Exception($this->lang("\x66\151\x6c\145\137\x61\143\x63\145\x73\x73") . $path, self::STOP_CONTINUE); } if ('' === $type) { $type = static::filenameToType($path); } $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME); if ('' === $name) { $name = $filename; } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("\x65\x6e\x63\x6f\144\x69\x6e\x67") . $encoding); } $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => $disposition, 7 => $name); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } public function getAttachments() { return $this->attachment; } protected function attachAll($disposition_type, $boundary) { $mime = array(); $cidUniq = array(); $incl = array(); foreach ($this->attachment as $attachment) { if ($attachment[6] === $disposition_type) { $string = ''; $path = ''; $bString = $attachment[5]; if ($bString) { $string = $attachment[0]; } else { $path = $attachment[0]; } $inclhash = hash("\x73\150\141\62\65\66", serialize($attachment)); if (in_array($inclhash, $incl, true)) { continue; } $incl[] = $inclhash; $name = $attachment[2]; $encoding = $attachment[3]; $type = $attachment[4]; $disposition = $attachment[6]; $cid = $attachment[7]; if ("\x69\x6e\x6c\151\x6e\x65" === $disposition && array_key_exists($cid, $cidUniq)) { continue; } $cidUniq[$cid] = true; $mime[] = sprintf("\x2d\x2d\x25\x73\45\163", $boundary, static::$LE); if (!empty($name)) { $mime[] = sprintf("\103\157\156\x74\x65\x6e\x74\55\x54\x79\160\x65\x3a\x20\x25\x73\73\40\x6e\141\155\145\75\x25\163\x25\x73", $type, static::quotedString($this->encodeHeader($this->secureHeader($name))), static::$LE); } else { $mime[] = sprintf("\x43\157\156\164\x65\x6e\164\x2d\124\x79\160\x65\72\40\x25\x73\45\x73", $type, static::$LE); } if (static::ENCODING_7BIT !== $encoding) { $mime[] = sprintf("\x43\x6f\156\164\x65\156\x74\55\x54\x72\x61\x6e\x73\x66\x65\162\x2d\x45\156\x63\157\x64\x69\x6e\147\x3a\x20\x25\163\45\163", $encoding, static::$LE); } if ((string) $cid !== '' && $disposition === "\x69\156\x6c\x69\156\x65") { $mime[] = "\103\157\x6e\x74\145\156\x74\55\111\104\72\x20\74" . $this->encodeHeader($this->secureHeader($cid)) . "\x3e" . static::$LE; } if (!empty($disposition)) { $encoded_name = $this->encodeHeader($this->secureHeader($name)); if (!empty($encoded_name)) { $mime[] = sprintf("\x43\157\156\164\145\x6e\164\55\104\x69\x73\160\157\163\151\x74\x69\157\x6e\72\40\45\x73\x3b\40\146\x69\x6c\145\156\141\155\x65\x3d\45\x73\x25\x73", $disposition, static::quotedString($encoded_name), static::$LE . static::$LE); } else { $mime[] = sprintf("\103\157\156\164\145\156\164\55\104\x69\163\160\x6f\x73\x69\164\x69\x6f\156\72\40\x25\x73\x25\x73", $disposition, static::$LE . static::$LE); } } else { $mime[] = static::$LE; } if ($bString) { $mime[] = $this->encodeString($string, $encoding); } else { $mime[] = $this->encodeFile($path, $encoding); } if ($this->isError()) { return ''; } $mime[] = static::$LE; } } $mime[] = sprintf("\x2d\55\x25\163\x2d\55\45\x73", $boundary, static::$LE); return implode('', $mime); } protected function encodeFile($path, $encoding = self::ENCODING_BASE64) { try { if (!static::fileIsAccessible($path)) { throw new Exception($this->lang("\146\x69\154\145\x5f\x6f\160\145\156") . $path, self::STOP_CONTINUE); } $file_buffer = file_get_contents($path); if (false === $file_buffer) { throw new Exception($this->lang("\146\151\154\145\x5f\x6f\160\145\x6e") . $path, self::STOP_CONTINUE); } $file_buffer = $this->encodeString($file_buffer, $encoding); return $file_buffer; } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return ''; } } public function encodeString($str, $encoding = self::ENCODING_BASE64) { $encoded = ''; switch (strtolower($encoding)) { case static::ENCODING_BASE64: $encoded = chunk_split(base64_encode($str), static::STD_LINE_LENGTH, static::$LE); break; case static::ENCODING_7BIT: case static::ENCODING_8BIT: $encoded = static::normalizeBreaks($str); if (substr($encoded, -strlen(static::$LE)) !== static::$LE) { $encoded .= static::$LE; } break; case static::ENCODING_BINARY: $encoded = $str; break; case static::ENCODING_QUOTED_PRINTABLE: $encoded = $this->encodeQP($str); break; default: $this->setError($this->lang("\x65\156\143\x6f\x64\151\156\147") . $encoding); if ($this->exceptions) { throw new Exception($this->lang("\145\x6e\143\157\x64\x69\x6e\147") . $encoding); } break; } return $encoded; } public function encodeHeader($str, $position = "\x74\145\x78\164") { $matchcount = 0; switch (strtolower($position)) { case "\160\x68\x72\x61\x73\x65": if (!preg_match("\57\133\134\62\60\x30\x2d\x5c\63\67\67\135\x2f", $str)) { $encoded = addcslashes($str, "\0\56\56\x1f\177\x5c\x22"); if ($str === $encoded && !preg_match("\x2f\x5b\x5e\x41\55\x5a\141\55\172\x30\55\71\41\43\44\x25\46\x27\52\x2b\x5c\57\75\x3f\x5e\137\x60\173\x7c\x7d\x7e\x20\55\x5d\57", $str)) { return $encoded; } return "\x22{$encoded}\x22"; } $matchcount = preg_match_all("\x2f\133\x5e\134\60\x34\x30\134\60\x34\x31\x5c\x30\64\63\55\x5c\61\x33\x33\134\x31\63\x35\55\134\61\67\66\135\57", $str, $matches); break; case "\x63\x6f\155\x6d\x65\x6e\164": $matchcount = preg_match_all("\x2f\x5b\x28\51\42\135\57", $str, $matches); case "\x74\x65\170\164": default: $matchcount += preg_match_all("\x2f\133\x5c\60\x30\x30\55\134\x30\x31\x30\x5c\x30\61\x33\x5c\60\x31\64\x5c\60\x31\x36\x2d\x5c\x30\x33\x37\x5c\x31\67\x37\55\134\x33\67\x37\x5d\x2f", $str, $matches); break; } if ($this->has8bitChars($str)) { $charset = $this->CharSet; } else { $charset = static::CHARSET_ASCII; } $overhead = 8 + strlen($charset); if ("\x6d\x61\151\x6c" === $this->Mailer) { $maxlen = static::MAIL_MAX_LINE_LENGTH - $overhead; } else { $maxlen = static::MAX_LINE_LENGTH - $overhead; } if ($matchcount > strlen($str) / 3) { $encoding = "\102"; } elseif ($matchcount > 0) { $encoding = "\121"; } elseif (strlen($str) > $maxlen) { $encoding = "\121"; } else { $encoding = false; } switch ($encoding) { case "\x42": if ($this->hasMultiBytes($str)) { $encoded = $this->base64EncodeWrapMB($str, "\12"); } else { $encoded = base64_encode($str); $maxlen -= $maxlen % 4; $encoded = trim(chunk_split($encoded, $maxlen, "\12")); } $encoded = preg_replace("\57\x5e\x28\56\x2a\51\x24\x2f\x6d", "\40\75\x3f" . $charset . "\77{$encoding}\x3f\x5c\x31\77\x3d", $encoded); break; case "\x51": $encoded = $this->encodeQ($str, $position); $encoded = $this->wrapText($encoded, $maxlen, true); $encoded = str_replace("\x3d" . static::$LE, "\12", trim($encoded)); $encoded = preg_replace("\x2f\136\x28\56\x2a\x29\44\x2f\x6d", "\40\75\x3f" . $charset . "\77{$encoding}\77\134\61\77\75", $encoded); break; default: return $str; } return trim(static::normalizeBreaks($encoded)); } public function hasMultiBytes($str) { if (function_exists("\155\x62\x5f\x73\x74\162\x6c\x65\156")) { return strlen($str) > mb_strlen($str, $this->CharSet); } return false; } public function has8bitChars($text) { return (bool) preg_match("\x2f\x5b\x5c\170\x38\60\x2d\134\170\x46\106\x5d\x2f", $text); } public function base64EncodeWrapMB($str, $linebreak = null) { $start = "\75\x3f" . $this->CharSet . "\77\x42\x3f"; $end = "\x3f\75"; $encoded = ''; if (null === $linebreak) { $linebreak = static::$LE; } $mb_length = mb_strlen($str, $this->CharSet); $length = 75 - strlen($start) - strlen($end); $ratio = $mb_length / strlen($str); $avgLength = floor($length * $ratio * 0.75); $offset = 0; for ($i = 0; $i < $mb_length; $i += $offset) { $lookBack = 0; do { $offset = $avgLength - $lookBack; $chunk = mb_substr($str, $i, $offset, $this->CharSet); $chunk = base64_encode($chunk); ++$lookBack; } while (strlen($chunk) > $length); $encoded .= $chunk . $linebreak; } return substr($encoded, 0, -strlen($linebreak)); } public function encodeQP($string) { return static::normalizeBreaks(quoted_printable_encode($string)); } public function encodeQ($str, $position = "\164\145\170\164") { $pattern = ''; $encoded = str_replace(array("\xd", "\xa"), '', $str); switch (strtolower($position)) { case "\160\150\162\141\x73\145": $pattern = "\136\x41\x2d\x5a\x61\x2d\172\x30\55\x39\x21\x2a\x2b\134\57\x20\x2d"; break; case "\143\157\x6d\155\x65\x6e\164": $pattern = "\x5c\50\x5c\x29\x22"; case "\164\145\x78\x74": default: $pattern = "\134\60\60\60\55\x5c\x30\x31\61\134\60\61\63\x5c\60\x31\64\x5c\60\61\x36\55\134\x30\63\67\134\x30\x37\65\x5c\x30\67\x37\x5c\x31\x33\x37\x5c\61\x37\x37\55\x5c\63\67\x37" . $pattern; break; } $matches = array(); if (preg_match_all("\x2f\133{$pattern}\135\x2f", $encoded, $matches)) { $eqkey = array_search("\x3d", $matches[0], true); if (false !== $eqkey) { unset($matches[0][$eqkey]); array_unshift($matches[0], "\75"); } foreach (array_unique($matches[0]) as $char) { $encoded = str_replace($char, "\x3d" . sprintf("\x25\60\62\x58", ord($char)), $encoded); } } return str_replace("\40", "\137", $encoded); } public function addStringAttachment($string, $filename, $encoding = self::ENCODING_BASE64, $type = '', $disposition = "\x61\164\164\141\143\x68\155\145\156\164") { try { if ('' === $type) { $type = static::filenameToType($filename); } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("\145\x6e\x63\x6f\x64\x69\156\x67") . $encoding); } $this->attachment[] = array(0 => $string, 1 => $filename, 2 => static::mb_pathinfo($filename, PATHINFO_BASENAME), 3 => $encoding, 4 => $type, 5 => true, 6 => $disposition, 7 => 0); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } public function addEmbeddedImage($path, $cid, $name = '', $encoding = self::ENCODING_BASE64, $type = '', $disposition = "\151\156\x6c\x69\x6e\x65") { try { if (!static::fileIsAccessible($path)) { throw new Exception($this->lang("\x66\151\x6c\x65\137\141\143\143\x65\163\163") . $path, self::STOP_CONTINUE); } if ('' === $type) { $type = static::filenameToType($path); } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("\x65\156\143\157\144\x69\x6e\x67") . $encoding); } $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME); if ('' === $name) { $name = $filename; } $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => $disposition, 7 => $cid); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } public function addStringEmbeddedImage($string, $cid, $name = '', $encoding = self::ENCODING_BASE64, $type = '', $disposition = "\x69\x6e\154\151\156\x65") { try { if ('' === $type && !empty($name)) { $type = static::filenameToType($name); } if (!$this->validateEncoding($encoding)) { throw new Exception($this->lang("\145\156\x63\157\x64\x69\156\147") . $encoding); } $this->attachment[] = array(0 => $string, 1 => $name, 2 => $name, 3 => $encoding, 4 => $type, 5 => true, 6 => $disposition, 7 => $cid); } catch (Exception $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; } protected function validateEncoding($encoding) { return in_array($encoding, array(self::ENCODING_7BIT, self::ENCODING_QUOTED_PRINTABLE, self::ENCODING_BASE64, self::ENCODING_8BIT, self::ENCODING_BINARY), true); } protected function cidExists($cid) { foreach ($this->attachment as $attachment) { if ("\151\x6e\x6c\x69\156\x65" === $attachment[6] && $cid === $attachment[7]) { return true; } } return false; } public function inlineImageExists() { foreach ($this->attachment as $attachment) { if ("\151\156\x6c\151\156\145" === $attachment[6]) { return true; } } return false; } public function attachmentExists() { foreach ($this->attachment as $attachment) { if ("\141\x74\x74\141\x63\150\x6d\145\x6e\x74" === $attachment[6]) { return true; } } return false; } public function alternativeExists() { return !empty($this->AltBody); } public function clearQueuedAddresses($kind) { $this->RecipientsQueue = array_filter($this->RecipientsQueue, static function ($params) use($kind) { return $params[0] !== $kind; }); } public function clearAddresses() { foreach ($this->to as $to) { unset($this->all_recipients[strtolower($to[0])]); } $this->to = array(); $this->clearQueuedAddresses("\164\157"); } public function clearCCs() { foreach ($this->cc as $cc) { unset($this->all_recipients[strtolower($cc[0])]); } $this->cc = array(); $this->clearQueuedAddresses("\143\x63"); } public function clearBCCs() { foreach ($this->bcc as $bcc) { unset($this->all_recipients[strtolower($bcc[0])]); } $this->bcc = array(); $this->clearQueuedAddresses("\x62\x63\143"); } public function clearReplyTos() { $this->ReplyTo = array(); $this->ReplyToQueue = array(); } public function clearAllRecipients() { $this->to = array(); $this->cc = array(); $this->bcc = array(); $this->all_recipients = array(); $this->RecipientsQueue = array(); } public function clearAttachments() { $this->attachment = array(); } public function clearCustomHeaders() { $this->CustomHeader = array(); } public function clearCustomHeader($name, $value = null) { if (null === $value && strpos($name, "\x3a") !== false) { list($name, $value) = explode("\x3a", $name, 2); } $name = trim($name); $value = null === $value ? null : trim($value); foreach ($this->CustomHeader as $k => $pair) { if ($pair[0] == $name) { if (null === $value || $pair[1] == $value) { unset($this->CustomHeader[$k]); } } } return true; } public function replaceCustomHeader($name, $value = null) { if (null === $value && strpos($name, "\x3a") !== false) { list($name, $value) = explode("\72", $name, 2); } $name = trim($name); $value = null === $value ? '' : trim($value); $replaced = false; foreach ($this->CustomHeader as $k => $pair) { if ($pair[0] == $name) { if ($replaced) { unset($this->CustomHeader[$k]); continue; } if (strpbrk($name . $value, "\15\xa") !== false) { if ($this->exceptions) { throw new Exception($this->lang("\x69\x6e\166\x61\154\151\x64\x5f\x68\145\x61\x64\x65\x72")); } return false; } $this->CustomHeader[$k] = array($name, $value); $replaced = true; } } return true; } protected function setError($msg) { ++$this->error_count; if ("\x73\x6d\x74\x70" === $this->Mailer && null !== $this->smtp) { $lasterror = $this->smtp->getError(); if (!empty($lasterror["\145\162\162\157\x72"])) { $msg .= $this->lang("\163\155\164\160\137\145\162\x72\x6f\x72") . $lasterror["\145\x72\x72\157\x72"]; if (!empty($lasterror["\x64\x65\x74\141\x69\154"])) { $msg .= "\x20" . $this->lang("\163\x6d\x74\160\x5f\x64\145\164\141\x69\x6c") . $lasterror["\144\x65\x74\x61\x69\154"]; } if (!empty($lasterror["\163\x6d\164\x70\137\x63\x6f\144\145"])) { $msg .= "\x20" . $this->lang("\163\x6d\x74\160\x5f\143\157\144\145") . $lasterror["\163\x6d\x74\160\137\143\x6f\x64\145"]; } if (!empty($lasterror["\x73\155\164\x70\x5f\x63\x6f\144\145\137\x65\x78"])) { $msg .= "\x20" . $this->lang("\163\155\164\x70\x5f\x63\157\x64\145\137\145\x78") . $lasterror["\163\x6d\164\x70\x5f\x63\x6f\x64\145\x5f\145\170"]; } } } $this->ErrorInfo = $msg; } public static function rfcDate() { date_default_timezone_set(@date_default_timezone_get()); return date("\104\x2c\40\152\x20\x4d\x20\x59\x20\x48\x3a\151\72\x73\40\x4f"); } protected function serverHostname() { $result = ''; if (!empty($this->Hostname)) { $result = $this->Hostname; } elseif (isset($_SERVER) && array_key_exists("\123\x45\122\x56\x45\122\137\116\x41\115\105", $_SERVER)) { $result = $_SERVER["\123\x45\x52\126\105\x52\x5f\x4e\x41\115\x45"]; } elseif (function_exists("\147\x65\164\x68\157\163\164\x6e\141\155\x65") && gethostname() !== false) { $result = gethostname(); } elseif (php_uname("\156") !== false) { $result = php_uname("\156"); } if (!static::isValidHost($result)) { return "\x6c\157\143\x61\x6c\x68\157\x73\x74\x2e\154\x6f\x63\141\x6c\x64\157\x6d\141\151\156"; } return $result; } public static function isValidHost($host) { if (empty($host) || !is_string($host) || strlen($host) > 256 || !preg_match("\x2f\136\50\x5b\141\55\x7a\x41\x2d\x5a\134\x64\x2e\55\135\52\x7c\x5c\x5b\133\141\55\146\101\55\x46\x5c\144\x3a\x5d\53\134\135\x29\44\57", $host)) { return false; } if (strlen($host) > 2 && substr($host, 0, 1) === "\133" && substr($host, -1, 1) === "\x5d") { return filter_var(substr($host, 1, -1), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false; } if (is_numeric(str_replace("\x2e", '', $host))) { return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false; } return filter_var("\150\164\164\x70\x73\72\57\57" . $host, FILTER_VALIDATE_URL) !== false; } protected function lang($key) { if (count($this->language) < 1) { $this->setLanguage(); } if (array_key_exists($key, $this->language)) { if ("\x73\155\x74\160\x5f\143\x6f\x6e\156\145\x63\x74\x5f\146\x61\151\x6c\145\144" === $key) { return $this->language[$key] . "\x20\150\x74\x74\x70\163\x3a\57\x2f\x67\151\x74\150\x75\x62\56\143\157\155\x2f\120\110\120\x4d\141\151\x6c\x65\162\x2f\120\x48\x50\x4d\x61\x69\x6c\145\x72\x2f\x77\151\x6b\x69\x2f\x54\x72\157\165\142\x6c\145\x73\x68\x6f\157\164\151\156\x67"; } return $this->language[$key]; } return $key; } private function getSmtpErrorMessage($base_key) { $message = $this->lang($base_key); $error = $this->smtp->getError(); if (!empty($error["\145\162\162\x6f\x72"])) { $message .= "\x20" . $error["\145\162\162\157\x72"]; if (!empty($error["\144\x65\164\x61\x69\x6c"])) { $message .= "\x20" . $error["\144\145\x74\x61\x69\x6c"]; } } return $message; } public function isError() { return $this->error_count > 0; } public function addCustomHeader($name, $value = null) { if (null === $value && strpos($name, "\72") !== false) { list($name, $value) = explode("\x3a", $name, 2); } $name = trim($name); $value = null === $value ? '' : trim($value); if (empty($name) || strpbrk($name . $value, "\15\12") !== false) { if ($this->exceptions) { throw new Exception($this->lang("\151\156\x76\141\x6c\x69\144\137\x68\x65\141\x64\x65\x72")); } return false; } $this->CustomHeader[] = array($name, $value); return true; } public function getCustomHeaders() { return $this->CustomHeader; } public function msgHTML($message, $basedir = '', $advanced = false) { preg_match_all("\57\50\x3f\74\x21\55\51\50\x73\162\x63\x7c\x62\141\143\x6b\147\x72\157\x75\x6e\x64\51\75\133\42\47\x5d\50\56\52\51\x5b\x22\47\x5d\x2f\x55\x69", $message, $images); if (array_key_exists(2, $images)) { if (strlen($basedir) > 1 && "\57" !== substr($basedir, -1)) { $basedir .= "\x2f"; } foreach ($images[2] as $imgindex => $url) { $match = array(); if (preg_match("\43\x5e\144\x61\164\x61\72\x28\151\x6d\x61\x67\145\x2f\x28\77\72\152\160\145\77\147\174\147\x69\146\x7c\160\156\x67\x29\x29\73\77\x28\x62\x61\x73\145\x36\x34\x29\77\54\x28\x2e\x2b\51\43", $url, $match)) { if (count($match) === 4 && static::ENCODING_BASE64 === $match[2]) { $data = base64_decode($match[3]); } elseif ('' === $match[2]) { $data = rawurldecode($match[3]); } else { continue; } $cid = substr(hash("\163\150\141\62\65\x36", $data), 0, 32) . "\x40\x70\x68\x70\155\x61\x69\x6c\x65\162\56\60"; if (!$this->cidExists($cid)) { $this->addStringEmbeddedImage($data, $cid, "\145\x6d\x62\x65\144" . $imgindex, static::ENCODING_BASE64, $match[1]); } $message = str_replace($images[0][$imgindex], $images[1][$imgindex] . "\x3d\x22\143\151\x64\72" . $cid . "\x22", $message); continue; } if (!empty($basedir) && strpos($url, "\56\x2e") === false && 0 !== strpos($url, "\x63\151\x64\72") && !preg_match("\x23\136\133\141\55\x7a\x5d\x5b\141\55\x7a\x30\x2d\71\x2b\56\x2d\x5d\x2a\x3a\77\x2f\x2f\x23\151", $url)) { $filename = static::mb_pathinfo($url, PATHINFO_BASENAME); $directory = dirname($url); if ("\56" === $directory) { $directory = ''; } $cid = substr(hash("\163\150\141\x32\x35\66", $url), 0, 32) . "\x40\160\150\x70\x6d\141\x69\154\145\x72\56\60"; if (strlen($basedir) > 1 && "\x2f" !== substr($basedir, -1)) { $basedir .= "\x2f"; } if (strlen($directory) > 1 && "\x2f" !== substr($directory, -1)) { $directory .= "\57"; } if ($this->addEmbeddedImage($basedir . $directory . $filename, $cid, $filename, static::ENCODING_BASE64, static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION)))) { $message = preg_replace("\x2f" . $images[1][$imgindex] . "\75\x5b\x22\x27\x5d" . preg_quote($url, "\57") . "\133\42\47\135\57\x55\151", $images[1][$imgindex] . "\75\42\x63\x69\x64\72" . $cid . "\x22", $message); } } } } $this->isHTML(); $this->Body = static::normalizeBreaks($message); $this->AltBody = static::normalizeBreaks($this->html2text($message, $advanced)); if (!$this->alternativeExists()) { $this->AltBody = "\x54\150\x69\163\40\x69\163\x20\x61\x6e\40\x48\124\x4d\114\x2d\x6f\156\x6c\x79\x20\x6d\x65\x73\163\141\x67\145\x2e\40\124\x6f\x20\x76\151\145\x77\x20\151\x74\54\40\141\x63\164\151\x76\x61\x74\145\40\110\x54\115\114\x20\x69\x6e\40\171\x6f\x75\x72\x20\145\x6d\x61\151\x6c\x20\141\x70\160\x6c\151\143\x61\x74\x69\x6f\x6e\x2e" . static::$LE; } return $this->Body; } public function html2text($html, $advanced = false) { if (is_callable($advanced)) { return call_user_func($advanced, $html); } return html_entity_decode(trim(strip_tags(preg_replace("\57\74\50\x68\x65\x61\144\174\164\x69\x74\154\x65\x7c\163\164\x79\154\145\174\x73\x63\x72\151\160\x74\51\x5b\136\76\135\x2a\76\56\x2a\77\x3c\134\57\134\x31\76\57\163\151", '', $html))), ENT_QUOTES, $this->CharSet); } public static function _mime_types($ext = '') { $mimes = array("\170\x6c" => "\141\160\160\x6c\151\143\x61\x74\151\157\x6e\x2f\145\x78\x63\145\x6c", "\152\163" => "\x61\x70\x70\154\x69\143\x61\164\x69\x6f\x6e\57\x6a\x61\x76\x61\163\143\x72\151\160\164", "\150\x71\170" => "\x61\160\x70\154\151\x63\141\164\x69\157\x6e\x2f\155\141\143\55\142\x69\x6e\150\145\170\x34\x30", "\x63\x70\x74" => "\x61\x70\x70\x6c\151\143\141\164\151\157\x6e\57\155\x61\143\55\143\157\155\x70\141\143\x74\160\x72\x6f", "\142\x69\156" => "\x61\160\160\x6c\x69\143\141\x74\x69\x6f\156\x2f\x6d\141\143\x62\151\x6e\141\162\171", "\x64\157\x63" => "\x61\x70\x70\154\x69\x63\141\x74\151\x6f\x6e\x2f\x6d\x73\167\157\162\144", "\167\157\x72\x64" => "\x61\x70\160\x6c\151\x63\141\164\151\x6f\156\x2f\x6d\163\167\x6f\x72\144", "\170\x6c\x73\170" => "\141\x70\x70\154\x69\x63\141\x74\151\157\x6e\57\x76\156\144\x2e\x6f\160\145\x6e\x78\x6d\154\x66\x6f\x72\155\x61\x74\163\55\157\146\146\x69\143\145\x64\157\143\165\155\145\156\164\56\x73\x70\x72\x65\x61\144\x73\150\x65\145\164\155\x6c\56\163\x68\x65\x65\x74", "\170\x6c\164\x78" => "\x61\160\160\154\x69\x63\x61\x74\x69\157\156\57\x76\x6e\x64\56\x6f\160\x65\x6e\x78\x6d\x6c\x66\x6f\x72\155\141\164\x73\55\x6f\146\x66\x69\143\x65\144\157\x63\x75\155\145\156\164\56\163\x70\x72\x65\141\x64\x73\x68\x65\145\164\x6d\x6c\x2e\164\x65\155\x70\154\x61\164\145", "\x70\157\164\170" => "\141\160\x70\154\x69\143\141\164\x69\157\156\57\x76\156\144\56\x6f\x70\x65\x6e\x78\x6d\x6c\x66\x6f\162\155\x61\x74\163\55\157\x66\x66\x69\x63\145\x64\x6f\143\x75\x6d\x65\x6e\x74\56\x70\162\145\x73\x65\x6e\x74\141\164\x69\157\x6e\x6d\x6c\x2e\164\145\x6d\160\x6c\x61\x74\x65", "\x70\160\x73\x78" => "\x61\x70\160\x6c\151\x63\141\164\151\157\156\57\166\x6e\x64\56\x6f\160\x65\x6e\170\x6d\154\x66\x6f\162\x6d\141\164\x73\x2d\x6f\146\x66\x69\143\145\x64\x6f\143\165\155\x65\x6e\164\56\x70\162\145\x73\x65\x6e\x74\141\164\151\x6f\x6e\x6d\154\56\163\x6c\x69\144\145\163\150\157\x77", "\x70\x70\164\170" => "\x61\160\x70\154\x69\143\141\164\x69\x6f\156\x2f\166\156\x64\56\x6f\160\x65\156\x78\155\x6c\146\x6f\x72\155\141\164\163\55\x6f\146\x66\x69\x63\x65\x64\x6f\x63\165\x6d\145\x6e\x74\56\x70\x72\145\163\x65\x6e\x74\141\164\151\157\x6e\x6d\x6c\56\160\x72\x65\163\145\156\164\141\x74\151\x6f\156", "\x73\154\144\x78" => "\x61\160\x70\x6c\x69\143\x61\x74\151\x6f\x6e\x2f\166\x6e\144\56\x6f\160\145\x6e\170\x6d\x6c\x66\157\x72\x6d\141\164\x73\55\x6f\x66\x66\151\x63\145\144\157\x63\165\155\x65\x6e\164\56\x70\162\x65\163\x65\156\164\x61\x74\x69\x6f\x6e\x6d\154\x2e\x73\154\151\x64\145", "\x64\157\x63\170" => "\x61\x70\x70\154\x69\x63\141\164\151\157\x6e\x2f\x76\x6e\144\x2e\157\160\145\156\x78\x6d\154\146\157\x72\155\x61\164\x73\55\157\x66\x66\151\143\x65\144\157\x63\x75\155\x65\156\164\x2e\x77\157\x72\144\x70\162\157\x63\x65\x73\163\151\156\147\x6d\154\56\144\x6f\x63\x75\x6d\x65\156\164", "\144\157\x74\170" => "\141\160\x70\x6c\151\143\141\164\151\157\156\x2f\166\156\144\x2e\157\x70\145\156\x78\155\x6c\146\157\x72\x6d\x61\164\x73\x2d\x6f\x66\146\x69\x63\x65\x64\157\143\165\x6d\x65\x6e\164\56\x77\157\x72\144\x70\x72\157\x63\145\163\x73\x69\156\147\155\x6c\56\164\x65\x6d\x70\x6c\x61\164\145", "\170\x6c\141\155" => "\141\160\x70\x6c\x69\143\x61\x74\x69\x6f\156\57\x76\x6e\x64\56\x6d\x73\55\x65\x78\x63\x65\154\x2e\x61\x64\144\151\x6e\x2e\155\141\x63\162\157\105\x6e\141\142\x6c\145\x64\56\61\62", "\170\x6c\163\142" => "\x61\160\160\x6c\x69\143\141\164\151\157\156\x2f\x76\x6e\144\56\155\x73\55\145\x78\x63\145\x6c\56\163\150\145\145\164\56\x62\151\x6e\x61\162\171\56\x6d\141\143\x72\157\x45\x6e\x61\142\x6c\145\144\x2e\x31\62", "\143\x6c\x61\x73\163" => "\x61\160\160\x6c\x69\x63\141\164\x69\157\x6e\x2f\157\x63\x74\x65\x74\x2d\x73\x74\162\145\x61\155", "\x64\154\154" => "\141\160\160\x6c\x69\x63\141\164\151\x6f\x6e\x2f\x6f\x63\164\x65\x74\x2d\163\164\162\145\141\x6d", "\144\x6d\x73" => "\x61\x70\160\154\151\143\x61\x74\x69\157\x6e\x2f\157\x63\x74\145\164\55\x73\164\x72\x65\141\x6d", "\145\x78\145" => "\141\x70\160\x6c\151\143\x61\x74\151\x6f\x6e\x2f\x6f\x63\x74\145\x74\55\x73\x74\x72\145\141\155", "\x6c\150\x61" => "\x61\160\160\x6c\151\x63\141\x74\x69\x6f\156\x2f\x6f\143\164\145\x74\55\163\x74\162\x65\141\155", "\x6c\x7a\150" => "\141\160\x70\154\x69\x63\x61\x74\x69\x6f\156\x2f\157\143\164\x65\x74\55\x73\164\162\145\141\x6d", "\x70\x73\x64" => "\141\x70\x70\154\151\x63\141\x74\151\157\x6e\x2f\x6f\143\164\145\x74\x2d\163\x74\162\145\x61\x6d", "\163\x65\141" => "\141\x70\160\x6c\x69\x63\141\x74\x69\x6f\x6e\57\157\x63\x74\x65\164\x2d\x73\x74\x72\145\141\155", "\163\x6f" => "\141\x70\160\154\151\143\x61\164\x69\x6f\x6e\57\x6f\x63\164\145\x74\x2d\x73\x74\162\145\141\155", "\x6f\144\x61" => "\141\x70\x70\154\151\x63\x61\164\x69\157\156\x2f\x6f\x64\141", "\x70\x64\146" => "\x61\160\x70\154\x69\x63\x61\164\151\x6f\x6e\x2f\x70\x64\x66", "\x61\x69" => "\141\160\160\154\x69\143\141\164\151\x6f\156\57\x70\157\163\x74\x73\x63\x72\151\160\x74", "\x65\x70\x73" => "\x61\x70\160\x6c\x69\143\141\x74\151\157\x6e\57\x70\x6f\163\x74\163\143\x72\x69\160\164", "\x70\x73" => "\141\x70\160\154\x69\143\x61\x74\151\x6f\x6e\57\160\157\x73\164\163\143\x72\151\160\164", "\163\x6d\x69" => "\x61\160\x70\x6c\151\143\x61\x74\151\x6f\x6e\x2f\x73\x6d\151\x6c", "\163\155\151\154" => "\x61\160\x70\x6c\151\x63\x61\164\x69\157\156\x2f\163\x6d\151\154", "\155\x69\146" => "\141\x70\x70\x6c\151\143\141\x74\x69\157\156\57\166\x6e\144\x2e\x6d\151\x66", "\170\x6c\163" => "\x61\160\160\x6c\x69\x63\x61\x74\x69\x6f\x6e\57\x76\x6e\x64\56\x6d\x73\x2d\145\170\143\145\x6c", "\x70\160\164" => "\x61\160\x70\x6c\151\x63\141\x74\x69\x6f\156\x2f\x76\156\x64\x2e\x6d\163\x2d\x70\x6f\167\145\x72\x70\x6f\151\x6e\x74", "\x77\x62\170\155\x6c" => "\141\x70\x70\154\151\143\141\164\151\157\156\x2f\x76\156\144\x2e\x77\141\160\56\167\x62\170\155\x6c", "\167\x6d\x6c\143" => "\x61\x70\x70\154\151\x63\x61\x74\151\x6f\156\57\166\x6e\x64\x2e\x77\x61\x70\x2e\167\x6d\x6c\x63", "\x64\x63\x72" => "\141\160\160\x6c\x69\x63\x61\x74\x69\157\156\57\x78\x2d\144\x69\x72\145\x63\164\157\x72", "\144\x69\162" => "\x61\x70\160\154\151\x63\141\x74\151\x6f\156\57\170\x2d\144\151\162\x65\143\x74\157\162", "\144\170\x72" => "\x61\x70\160\x6c\151\x63\141\x74\x69\x6f\x6e\x2f\170\x2d\x64\151\162\145\143\164\157\x72", "\x64\x76\x69" => "\141\160\160\154\151\x63\141\x74\151\157\x6e\x2f\x78\x2d\144\x76\x69", "\x67\x74\x61\x72" => "\x61\160\160\154\x69\143\141\164\151\157\x6e\x2f\170\55\147\x74\x61\162", "\x70\x68\160\x33" => "\x61\160\160\154\151\143\141\x74\x69\x6f\x6e\x2f\170\55\150\x74\x74\x70\144\x2d\x70\150\160", "\x70\x68\160\64" => "\x61\x70\x70\154\151\x63\x61\164\x69\x6f\x6e\57\170\55\x68\x74\x74\160\x64\55\160\150\x70", "\160\150\160" => "\141\x70\160\x6c\151\x63\141\x74\x69\x6f\x6e\x2f\x78\55\x68\x74\x74\160\144\55\x70\x68\x70", "\x70\x68\164\155\x6c" => "\x61\160\x70\x6c\151\143\x61\x74\151\x6f\x6e\57\170\55\150\x74\x74\160\144\55\160\150\x70", "\160\x68\160\163" => "\x61\160\x70\154\151\143\x61\x74\x69\x6f\x6e\57\170\55\x68\164\164\x70\144\x2d\x70\x68\160\x2d\x73\157\x75\x72\x63\145", "\x73\x77\x66" => "\x61\x70\x70\154\x69\x63\141\x74\151\157\x6e\x2f\170\x2d\163\x68\x6f\143\x6b\167\141\166\145\x2d\x66\x6c\141\x73\150", "\163\151\x74" => "\141\160\160\154\x69\143\141\x74\151\157\156\57\170\x2d\x73\164\x75\x66\146\x69\x74", "\x74\x61\x72" => "\x61\160\x70\154\x69\x63\141\x74\x69\157\156\57\x78\55\164\x61\162", "\164\147\172" => "\x61\x70\x70\x6c\x69\x63\x61\164\151\x6f\x6e\x2f\170\x2d\x74\141\162", "\x78\x68\x74" => "\x61\160\160\154\151\143\x61\164\x69\x6f\x6e\x2f\x78\x68\x74\155\154\x2b\170\x6d\x6c", "\170\150\x74\x6d\154" => "\141\160\x70\154\151\x63\x61\164\x69\x6f\156\x2f\x78\150\x74\155\x6c\x2b\170\155\154", "\172\x69\x70" => "\141\160\160\154\151\143\x61\164\151\x6f\x6e\57\172\x69\160", "\155\151\144" => "\x61\x75\144\151\x6f\57\155\x69\144\151", "\x6d\151\x64\x69" => "\141\x75\144\x69\x6f\x2f\155\x69\144\x69", "\x6d\160\62" => "\x61\165\144\x69\x6f\57\155\160\x65\x67", "\x6d\x70\x33" => "\141\165\144\151\x6f\x2f\x6d\x70\x65\x67", "\155\64\141" => "\141\x75\x64\x69\x6f\57\x6d\160\x34", "\x6d\160\x67\x61" => "\141\165\x64\151\157\x2f\155\x70\145\147", "\141\x69\146" => "\141\x75\x64\x69\157\x2f\170\x2d\x61\x69\146\146", "\141\151\x66\x63" => "\141\165\144\151\157\x2f\x78\x2d\x61\151\x66\146", "\x61\151\x66\x66" => "\x61\165\x64\151\157\57\x78\x2d\x61\151\x66\146", "\162\141\155" => "\x61\x75\144\x69\157\x2f\170\x2d\160\156\55\x72\145\x61\x6c\141\x75\x64\x69\157", "\162\x6d" => "\141\165\x64\x69\x6f\x2f\170\x2d\x70\x6e\55\162\x65\x61\x6c\141\165\144\x69\157", "\162\160\x6d" => "\141\165\144\151\x6f\x2f\170\55\x70\x6e\55\162\x65\141\x6c\141\165\144\151\157\x2d\160\154\165\x67\x69\156", "\x72\141" => "\141\165\144\x69\x6f\x2f\x78\55\x72\x65\141\x6c\141\x75\144\x69\x6f", "\x77\141\x76" => "\x61\165\x64\151\157\x2f\170\55\167\141\166", "\x6d\x6b\x61" => "\x61\x75\x64\151\157\57\x78\x2d\155\x61\x74\x72\x6f\163\153\x61", "\x62\155\x70" => "\151\155\x61\x67\145\57\x62\155\x70", "\147\151\x66" => "\x69\x6d\141\x67\145\x2f\x67\151\146", "\152\x70\145\147" => "\x69\x6d\141\x67\x65\x2f\x6a\x70\145\x67", "\x6a\x70\145" => "\x69\x6d\x61\x67\145\57\152\x70\x65\147", "\152\160\147" => "\151\x6d\141\147\145\57\152\x70\x65\147", "\x70\156\147" => "\151\x6d\141\147\x65\x2f\160\x6e\147", "\x74\151\x66\x66" => "\x69\x6d\141\147\x65\57\164\151\x66\146", "\164\151\x66" => "\151\x6d\141\x67\145\x2f\164\151\146\x66", "\x77\145\x62\x70" => "\x69\x6d\141\x67\145\x2f\167\x65\x62\x70", "\141\166\151\146" => "\151\x6d\x61\x67\145\57\x61\166\x69\x66", "\150\145\151\146" => "\x69\x6d\141\147\145\57\150\x65\151\146", "\x68\x65\151\x66\x73" => "\x69\155\x61\147\145\57\150\x65\151\x66\55\x73\145\x71\x75\145\156\x63\x65", "\150\145\151\143" => "\151\x6d\141\147\x65\57\x68\x65\x69\143", "\x68\145\x69\x63\163" => "\x69\155\141\147\145\57\x68\145\151\x63\x2d\x73\145\x71\165\x65\156\x63\x65", "\x65\155\x6c" => "\155\145\x73\163\x61\x67\145\x2f\x72\x66\143\70\x32\62", "\x63\x73\x73" => "\x74\145\170\x74\57\143\x73\163", "\x68\x74\x6d\x6c" => "\164\145\170\164\x2f\x68\x74\155\154", "\x68\x74\155" => "\164\x65\x78\164\x2f\x68\164\x6d\x6c", "\163\150\x74\155\154" => "\x74\x65\x78\164\x2f\150\x74\155\x6c", "\154\x6f\x67" => "\x74\145\x78\164\x2f\x70\x6c\141\x69\156", "\164\x65\x78\164" => "\x74\145\x78\x74\x2f\160\x6c\x61\x69\x6e", "\164\170\164" => "\x74\x65\x78\x74\57\160\x6c\141\151\x6e", "\x72\164\170" => "\x74\145\x78\x74\57\x72\151\x63\150\164\x65\170\164", "\x72\164\x66" => "\164\145\x78\164\x2f\162\164\x66", "\x76\x63\146" => "\164\145\170\164\x2f\x76\x63\x61\x72\x64", "\166\x63\141\x72\x64" => "\164\x65\x78\164\x2f\166\143\141\x72\144", "\x69\143\x73" => "\x74\x65\x78\x74\57\143\x61\x6c\145\156\x64\141\162", "\x78\x6d\x6c" => "\x74\145\x78\164\57\x78\x6d\x6c", "\170\x73\154" => "\164\145\x78\x74\x2f\x78\x6d\154", "\x63\x73\166" => "\x74\x65\170\x74\57\143\x73\166", "\167\155\166" => "\166\x69\144\x65\x6f\57\170\x2d\155\x73\x2d\x77\155\166", "\155\x70\x65\x67" => "\166\x69\x64\145\157\57\x6d\x70\145\x67", "\x6d\160\x65" => "\166\151\144\145\157\x2f\155\x70\145\x67", "\155\x70\x67" => "\x76\x69\144\x65\x6f\x2f\x6d\160\x65\147", "\155\x70\x34" => "\166\x69\x64\x65\157\57\x6d\x70\x34", "\x6d\64\x76" => "\166\x69\x64\x65\157\x2f\155\x70\x34", "\x6d\x6f\166" => "\166\151\x64\145\157\x2f\x71\165\151\143\153\x74\x69\x6d\145", "\161\164" => "\x76\x69\144\145\x6f\57\x71\165\151\x63\153\164\x69\x6d\145", "\162\x76" => "\x76\x69\x64\145\157\x2f\166\x6e\x64\56\162\156\x2d\x72\x65\141\x6c\166\x69\144\145\157", "\141\x76\151" => "\x76\151\x64\x65\x6f\x2f\x78\x2d\x6d\163\166\x69\144\x65\x6f", "\x6d\x6f\166\x69\x65" => "\166\x69\x64\x65\157\57\170\x2d\x73\147\151\x2d\x6d\157\x76\151\x65", "\x77\x65\x62\x6d" => "\166\151\144\x65\157\57\x77\x65\142\155", "\155\153\166" => "\166\x69\144\145\x6f\57\x78\55\x6d\141\164\x72\157\x73\x6b\x61"); $ext = strtolower($ext); if (array_key_exists($ext, $mimes)) { return $mimes[$ext]; } return "\x61\160\x70\x6c\151\143\x61\x74\x69\x6f\x6e\57\157\143\164\145\x74\55\x73\164\x72\x65\x61\155"; } public static function filenameToType($filename) { $qpos = strpos($filename, "\x3f"); if (false !== $qpos) { $filename = substr($filename, 0, $qpos); } $ext = static::mb_pathinfo($filename, PATHINFO_EXTENSION); return static::_mime_types($ext); } public static function mb_pathinfo($path, $options = null) { $ret = array("\x64\151\x72\156\x61\x6d\x65" => '', "\x62\141\163\x65\156\x61\x6d\x65" => '', "\145\x78\164\x65\x6e\163\x69\x6f\156" => '', "\x66\x69\154\x65\x6e\141\x6d\145" => ''); $pathinfo = array(); if (preg_match("\x23\x5e\50\x2e\52\77\x29\133\x5c\134\57\x5d\x2a\50\50\x5b\136\x2f\134\x5c\x5d\x2a\77\51\x28\x5c\56\50\133\136\56\x5c\x5c\x2f\x5d\x2b\77\x29\174\51\x29\x5b\134\134\57\56\x5d\52\44\x23\155", $path, $pathinfo)) { if (array_key_exists(1, $pathinfo)) { $ret["\144\151\x72\156\141\x6d\x65"] = $pathinfo[1]; } if (array_key_exists(2, $pathinfo)) { $ret["\142\x61\x73\145\156\141\155\x65"] = $pathinfo[2]; } if (array_key_exists(5, $pathinfo)) { $ret["\145\x78\164\145\156\x73\151\157\156"] = $pathinfo[5]; } if (array_key_exists(3, $pathinfo)) { $ret["\x66\151\x6c\x65\x6e\x61\x6d\145"] = $pathinfo[3]; } } switch ($options) { case PATHINFO_DIRNAME: case "\144\x69\162\x6e\x61\x6d\145": return $ret["\x64\x69\162\156\141\155\x65"]; case PATHINFO_BASENAME: case "\x62\141\x73\145\156\141\155\x65": return $ret["\x62\141\x73\145\x6e\141\x6d\x65"]; case PATHINFO_EXTENSION: case "\x65\170\164\x65\156\163\151\157\x6e": return $ret["\x65\x78\164\145\x6e\163\x69\157\x6e"]; case PATHINFO_FILENAME: case "\146\151\x6c\145\x6e\141\x6d\x65": return $ret["\146\151\154\145\156\141\155\145"]; default: return $ret; } } public function set($name, $value = '') { if (property_exists($this, $name)) { $this->{$name} = $value; return true; } $this->setError($this->lang("\166\x61\162\x69\141\x62\154\145\x5f\163\145\x74") . $name); return false; } public function secureHeader($str) { return trim(str_replace(array("\15", "\12"), '', $str)); } public static function normalizeBreaks($text, $breaktype = null) { if (null === $breaktype) { $breaktype = static::$LE; } $text = str_replace(array(self::CRLF, "\xd"), "\12", $text); if ("\12" !== $breaktype) { $text = str_replace("\xa", $breaktype, $text); } return $text; } public static function stripTrailingWSP($text) { return rtrim($text, "\40\xd\xa\x9"); } public static function stripTrailingBreaks($text) { return rtrim($text, "\xd\12"); } public static function getLE() { return static::$LE; } protected static function setLE($le) { static::$LE = $le; } public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '') { $this->sign_cert_file = $cert_filename; $this->sign_key_file = $key_filename; $this->sign_key_pass = $key_pass; $this->sign_extracerts_file = $extracerts_filename; } public function DKIM_QP($txt) { $line = ''; $len = strlen($txt); for ($i = 0; $i < $len; ++$i) { $ord = ord($txt[$i]); if (33 <= $ord && $ord <= 58 || $ord === 60 || 62 <= $ord && $ord <= 126) { $line .= $txt[$i]; } else { $line .= "\x3d" . sprintf("\45\x30\62\130", $ord); } } return $line; } public function DKIM_Sign($signHeader) { if (!defined("\x50\x4b\x43\x53\x37\x5f\x54\x45\x58\124")) { if ($this->exceptions) { throw new Exception($this->lang("\145\170\164\x65\x6e\163\151\x6f\x6e\137\155\x69\163\163\x69\156\x67") . "\x6f\160\145\156\x73\x73\154"); } return ''; } $privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private); if ('' !== $this->DKIM_passphrase) { $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); } else { $privKey = openssl_pkey_get_private($privKeyStr); } if (openssl_sign($signHeader, $signature, $privKey, "\163\x68\x61\x32\65\66\127\x69\164\150\x52\123\x41\x45\x6e\x63\x72\x79\x70\x74\151\x6f\156")) { if (\PHP_MAJOR_VERSION < 8) { openssl_pkey_free($privKey); } return base64_encode($signature); } if (\PHP_MAJOR_VERSION < 8) { openssl_pkey_free($privKey); } return ''; } public function DKIM_HeaderC($signHeader) { $signHeader = static::normalizeBreaks($signHeader, self::CRLF); $signHeader = preg_replace("\57\x5c\x72\x5c\156\133\x20\x5c\x74\135\x2b\x2f", "\40", $signHeader); $lines = explode(self::CRLF, $signHeader); foreach ($lines as $key => $line) { if (strpos($line, "\x3a") === false) { continue; } list($heading, $value) = explode("\72", $line, 2); $heading = strtolower($heading); $value = preg_replace("\x2f\133\x20\134\x74\135\x2b\x2f", "\40", $value); $lines[$key] = trim($heading, "\x20\11") . "\72" . trim($value, "\40\11"); } return implode(self::CRLF, $lines); } public function DKIM_BodyC($body) { if (empty($body)) { return self::CRLF; } $body = static::normalizeBreaks($body, self::CRLF); return static::stripTrailingBreaks($body) . self::CRLF; } public function DKIM_Add($headers_line, $subject, $body) { $DKIMsignatureType = "\162\x73\x61\55\x73\x68\141\62\65\66"; $DKIMcanonicalization = "\x72\145\154\141\170\145\x64\x2f\163\151\x6d\x70\x6c\145"; $DKIMquery = "\x64\156\x73\57\x74\170\164"; $DKIMtime = time(); $autoSignHeaders = array("\x66\x72\x6f\155", "\164\x6f", "\x63\x63", "\x64\x61\164\145", "\163\x75\x62\x6a\x65\x63\164", "\162\x65\160\x6c\x79\x2d\164\157", "\x6d\145\163\x73\141\147\x65\x2d\x69\x64", "\143\x6f\156\164\145\x6e\164\x2d\164\171\160\x65", "\155\x69\x6d\145\55\166\145\x72\x73\x69\157\x6e", "\170\55\x6d\x61\x69\x6c\x65\x72"); if (stripos($headers_line, "\x53\x75\x62\x6a\x65\143\x74") === false) { $headers_line .= "\123\165\142\x6a\145\x63\164\72\40" . $subject . static::$LE; } $headerLines = explode(static::$LE, $headers_line); $currentHeaderLabel = ''; $currentHeaderValue = ''; $parsedHeaders = array(); $headerLineIndex = 0; $headerLineCount = count($headerLines); foreach ($headerLines as $headerLine) { $matches = array(); if (preg_match("\57\x5e\50\133\x5e\40\x5c\164\135\52\77\51\x28\x3f\x3a\x3a\133\40\134\164\x5d\x2a\51\50\x2e\x2a\51\x24\x2f", $headerLine, $matches)) { if ($currentHeaderLabel !== '') { $parsedHeaders[] = array("\154\141\142\x65\x6c" => $currentHeaderLabel, "\x76\141\x6c\x75\x65" => $currentHeaderValue); } $currentHeaderLabel = $matches[1]; $currentHeaderValue = $matches[2]; } elseif (preg_match("\x2f\136\x5b\40\x5c\x74\135\x2b\x28\x2e\52\x29\x24\x2f", $headerLine, $matches)) { $currentHeaderValue .= "\40" . $matches[1]; } ++$headerLineIndex; if ($headerLineIndex >= $headerLineCount) { $parsedHeaders[] = array("\x6c\x61\x62\145\154" => $currentHeaderLabel, "\166\x61\154\x75\145" => $currentHeaderValue); } } $copiedHeaders = array(); $headersToSignKeys = array(); $headersToSign = array(); foreach ($parsedHeaders as $header) { if (in_array(strtolower($header["\154\x61\x62\x65\154"]), $autoSignHeaders, true)) { $headersToSignKeys[] = $header["\154\141\142\145\154"]; $headersToSign[] = $header["\x6c\141\x62\145\154"] . "\72\x20" . $header["\166\x61\154\x75\x65"]; if ($this->DKIM_copyHeaderFields) { $copiedHeaders[] = $header["\x6c\x61\142\145\x6c"] . "\x3a" . str_replace("\174", "\x3d\x37\x43", $this->DKIM_QP($header["\x76\141\x6c\x75\x65"])); } continue; } if (in_array($header["\x6c\x61\142\x65\154"], $this->DKIM_extraHeaders, true)) { foreach ($this->CustomHeader as $customHeader) { if ($customHeader[0] === $header["\x6c\141\x62\x65\x6c"]) { $headersToSignKeys[] = $header["\154\x61\x62\x65\x6c"]; $headersToSign[] = $header["\154\x61\142\x65\154"] . "\72\40" . $header["\x76\x61\154\165\x65"]; if ($this->DKIM_copyHeaderFields) { $copiedHeaders[] = $header["\154\x61\142\145\x6c"] . "\72" . str_replace("\x7c", "\75\x37\103", $this->DKIM_QP($header["\x76\141\154\x75\145"])); } continue 2; } } } } $copiedHeaderFields = ''; if ($this->DKIM_copyHeaderFields && count($copiedHeaders) > 0) { $copiedHeaderFields = "\x20\172\x3d"; $first = true; foreach ($copiedHeaders as $copiedHeader) { if (!$first) { $copiedHeaderFields .= static::$LE . "\x20\174"; } if (strlen($copiedHeader) > self::STD_LINE_LENGTH - 3) { $copiedHeaderFields .= substr(chunk_split($copiedHeader, self::STD_LINE_LENGTH - 3, static::$LE . self::FWS), 0, -strlen(static::$LE . self::FWS)); } else { $copiedHeaderFields .= $copiedHeader; } $first = false; } $copiedHeaderFields .= "\x3b" . static::$LE; } $headerKeys = "\x20\x68\75" . implode("\72", $headersToSignKeys) . "\x3b" . static::$LE; $headerValues = implode(static::$LE, $headersToSign); $body = $this->DKIM_BodyC($body); $DKIMb64 = base64_encode(pack("\110\x2a", hash("\163\x68\x61\62\x35\x36", $body))); $ident = ''; if ('' !== $this->DKIM_identity) { $ident = "\x20\x69\x3d" . $this->DKIM_identity . "\x3b" . static::$LE; } $dkimSignatureHeader = "\104\x4b\x49\x4d\x2d\123\151\147\156\x61\164\165\x72\x65\72\40\x76\75\x31\x3b" . "\x20\144\x3d" . $this->DKIM_domain . "\x3b" . "\40\163\75" . $this->DKIM_selector . "\x3b" . static::$LE . "\x20\141\x3d" . $DKIMsignatureType . "\73" . "\40\x71\75" . $DKIMquery . "\x3b" . "\x20\164\75" . $DKIMtime . "\73" . "\x20\x63\x3d" . $DKIMcanonicalization . "\x3b" . static::$LE . $headerKeys . $ident . $copiedHeaderFields . "\40\142\150\75" . $DKIMb64 . "\73" . static::$LE . "\x20\x62\x3d"; $canonicalizedHeaders = $this->DKIM_HeaderC($headerValues . static::$LE . $dkimSignatureHeader); $signature = $this->DKIM_Sign($canonicalizedHeaders); $signature = trim(chunk_split($signature, self::STD_LINE_LENGTH - 3, static::$LE . self::FWS)); return static::normalizeBreaks($dkimSignatureHeader . $signature); } public static function hasLineLongerThanMax($str) { return (bool) preg_match("\57\x5e\x28\x2e\x7b" . (self::MAX_LINE_LENGTH + strlen(static::$LE)) . "\x2c\175\x29\57\155", $str); } public static function quotedString($str) { if (preg_match("\57\133\x20\50\51\74\x3e\x40\x2c\73\x3a\x22\x5c\x2f\x5c\133\134\x5d\x3f\75\135\x2f", $str)) { return "\x22" . str_replace("\x22", "\x5c\42", $str) . "\42"; } return $str; } public function getToAddresses() { return $this->to; } public function getCcAddresses() { return $this->cc; } public function getBccAddresses() { return $this->bcc; } public function getReplyToAddresses() { return $this->ReplyTo; } public function getAllRecipientAddresses() { return $this->all_recipients; } protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra) { if (!empty($this->action_function) && is_callable($this->action_function)) { call_user_func($this->action_function, $isSent, $to, $cc, $bcc, $subject, $body, $from, $extra); } } public function getOAuth() { return $this->oauth; } public function setOAuth(OAuthTokenProvider $oauth) { $this->oauth = $oauth; } }

Function Calls

None

Variables

None

Stats

MD5 4b38c9b9d5d01440e495b40605496ac3
Eval Count 0
Decode Time 172 ms