From e639b2d6ef4e5a4d7491e474262e3af91973cb56 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Thu, 4 May 2023 22:29:50 +0800 Subject: [PATCH] PHPMailer --- class/Mailer/PHPMailer/DSNConfigurator.php | 10 +++-- class/Mailer/PHPMailer/Exception.php | 3 +- class/Mailer/PHPMailer/OAuth.php | 3 +- class/Mailer/PHPMailer/OAuthTokenProvider.php | 3 +- class/Mailer/PHPMailer/PHPMailer.php | 45 ++++++++++++------- class/Mailer/PHPMailer/POP3.php | 5 ++- class/Mailer/PHPMailer/SMTP.php | 9 ++-- 7 files changed, 51 insertions(+), 27 deletions(-) diff --git a/class/Mailer/PHPMailer/DSNConfigurator.php b/class/Mailer/PHPMailer/DSNConfigurator.php index a53a7db..52ec8e9 100644 --- a/class/Mailer/PHPMailer/DSNConfigurator.php +++ b/class/Mailer/PHPMailer/DSNConfigurator.php @@ -1,11 +1,15 @@ $value) { if (!in_array($key, $allowedOptions)) { @@ -215,7 +219,7 @@ private function configureOptions(PHPMailer $mailer, $options) */ protected function parseUrl($url) { - if (\PHP_VERSION_ID >= 50600 || false === strpos($url, '?')) { + if (PHP_VERSION_ID >= 50600 || false === strpos($url, '?')) { return parse_url($url); } diff --git a/class/Mailer/PHPMailer/Exception.php b/class/Mailer/PHPMailer/Exception.php index 4e66c85..773e655 100644 --- a/class/Mailer/PHPMailer/Exception.php +++ b/class/Mailer/PHPMailer/Exception.php @@ -1,11 +1,12 @@ Debugoutput instanceof \Psr\Log\LoggerInterface) { + if ($this->Debugoutput instanceof LoggerInterface) { $this->Debugoutput->debug($str); return; @@ -930,7 +943,7 @@ protected function edebug($str) * * @param bool $isHtml True for HTML mode */ - public function isHTML(bool $isHtml = true) + public function isHTML($isHtml = true) { if ($isHtml) { $this->ContentType = static::CONTENT_TYPE_TEXT_HTML; @@ -1464,13 +1477,13 @@ public function punyencodeAddress($address) //Use the current punycode standard (appeared in PHP 7.2) $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 + 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')) { //Fall back to this old, deprecated/removed encoding - $punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_2003); + $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_2003); } else { //Fall back to a default we don't know about $punycode = idn_to_ascii($domain, $errorcode); @@ -1522,7 +1535,7 @@ public function preSend() { if ( 'smtp' === $this->Mailer - || ('mail' === $this->Mailer && (\PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0)) + || ('mail' === $this->Mailer && (PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0)) ) { //SMTP mandates RFC-compliant line endings //and it's also used with mail() on Windows @@ -1534,8 +1547,8 @@ public function preSend() //Check for buggy PHP versions that add a header with an incorrect line break if ( 'mail' === $this->Mailer - && ((\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70017) - || (\PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70103)) + && ((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 ) { @@ -1995,7 +2008,7 @@ public function setSMTPInstance(SMTP $smtp) * * @see PHPMailer::setSMTPInstance() to use a different class. * - * @uses \Mailer\PHPMailer\SMTP + * @uses SMTP * */ protected function smtpSend($header, $body) @@ -2080,7 +2093,7 @@ protected function smtpSend($header, $body) * @return bool * @throws Exception * - * @uses \Mailer\PHPMailer\SMTP + * @uses SMTP * */ public function smtpConnect($options = null) @@ -2767,7 +2780,7 @@ protected function generateId() if (function_exists('random_bytes')) { try { $bytes = random_bytes($len); - } catch (\Exception $e) { + } catch (Exception $e) { //Do nothing } } elseif (function_exists('openssl_random_pseudo_bytes')) { @@ -4760,13 +4773,13 @@ public function DKIM_Sign($signHeader) $privKey = openssl_pkey_get_private($privKeyStr); } if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) { - if (\PHP_MAJOR_VERSION < 8) { + if (PHP_MAJOR_VERSION < 8) { openssl_pkey_free($privKey); } return base64_encode($signature); } - if (\PHP_MAJOR_VERSION < 8) { + if (PHP_MAJOR_VERSION < 8) { openssl_pkey_free($privKey); } diff --git a/class/Mailer/PHPMailer/POP3.php b/class/Mailer/PHPMailer/POP3.php index 6f46698..2cf66bd 100644 --- a/class/Mailer/PHPMailer/POP3.php +++ b/class/Mailer/PHPMailer/POP3.php @@ -1,14 +1,15 @@ Debugoutput = new myPsr3Logger; * ``` * - * @var string|callable|\Psr\Log\LoggerInterface + * @var string|callable|LoggerInterface */ public $Debugoutput = 'echo'; @@ -253,7 +256,7 @@ protected function edebug($str, $level = 0) return; } //Is this a PSR-3 logger? - if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) { + if ($this->Debugoutput instanceof LoggerInterface) { $this->Debugoutput->debug($str); return;