forked from XiaoLFeng/XF_Index
PHPMailer
This commit is contained in:
parent
7fec6f19a4
commit
e639b2d6ef
@ -1,11 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||||
* https://www.x-lf.com/
|
* https://www.x-lf.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailer\PHPMailer;
|
namespace Mailer;
|
||||||
|
|
||||||
|
use function array_keys;
|
||||||
|
use const PHP_VERSION_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure PHPMailer with DSN string.
|
* Configure PHPMailer with DSN string.
|
||||||
@ -170,7 +174,7 @@ private function configureOptions(PHPMailer $mailer, $options)
|
|||||||
unset($allowedOptions['Port']);
|
unset($allowedOptions['Port']);
|
||||||
unset($allowedOptions['ErrorInfo']);
|
unset($allowedOptions['ErrorInfo']);
|
||||||
|
|
||||||
$allowedOptions = \array_keys($allowedOptions);
|
$allowedOptions = array_keys($allowedOptions);
|
||||||
|
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
if (!in_array($key, $allowedOptions)) {
|
if (!in_array($key, $allowedOptions)) {
|
||||||
@ -215,7 +219,7 @@ private function configureOptions(PHPMailer $mailer, $options)
|
|||||||
*/
|
*/
|
||||||
protected function parseUrl($url)
|
protected function parseUrl($url)
|
||||||
{
|
{
|
||||||
if (\PHP_VERSION_ID >= 50600 || false === strpos($url, '?')) {
|
if (PHP_VERSION_ID >= 50600 || false === strpos($url, '?')) {
|
||||||
return parse_url($url);
|
return parse_url($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||||
* https://www.x-lf.com/
|
* https://www.x-lf.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailer\PHPMailer;
|
namespace Mailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPMailer exception handler.
|
* PHPMailer exception handler.
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||||
* https://www.x-lf.com/
|
* https://www.x-lf.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailer\PHPMailer;
|
namespace Mailer;
|
||||||
|
|
||||||
use League\OAuth2\Client\Grant\RefreshToken;
|
use League\OAuth2\Client\Grant\RefreshToken;
|
||||||
use League\OAuth2\Client\Provider\AbstractProvider;
|
use League\OAuth2\Client\Provider\AbstractProvider;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||||
* https://www.x-lf.com/
|
* https://www.x-lf.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailer\PHPMailer;
|
namespace Mailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OAuthTokenProvider - OAuth2 token provider interface.
|
* OAuthTokenProvider - OAuth2 token provider interface.
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||||
* https://www.x-lf.com/
|
* https://www.x-lf.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailer\PHPMailer;
|
namespace Mailer;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use const IDNA_CHECK_BIDI;
|
||||||
|
use const IDNA_CHECK_CONTEXTJ;
|
||||||
|
use const IDNA_DEFAULT;
|
||||||
|
use const IDNA_NONTRANSITIONAL_TO_ASCII;
|
||||||
|
use const IDNA_USE_STD3_RULES;
|
||||||
|
use const INTL_IDNA_VARIANT_2003;
|
||||||
|
use const INTL_IDNA_VARIANT_UTS46;
|
||||||
|
use const PHP_MAJOR_VERSION;
|
||||||
|
use const PHP_VERSION_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPMailer - PHP email creation and transport class.
|
* PHPMailer - PHP email creation and transport class.
|
||||||
@ -409,7 +422,7 @@ class PHPMailer
|
|||||||
*
|
*
|
||||||
* @see SMTP::$Debugoutput
|
* @see SMTP::$Debugoutput
|
||||||
*
|
*
|
||||||
* @var string|callable|\Psr\Log\LoggerInterface
|
* @var string|callable|LoggerInterface
|
||||||
*/
|
*/
|
||||||
public $Debugoutput = 'echo';
|
public $Debugoutput = 'echo';
|
||||||
|
|
||||||
@ -881,7 +894,7 @@ protected function edebug($str)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Is this a PSR-3 logger?
|
//Is this a PSR-3 logger?
|
||||||
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
|
if ($this->Debugoutput instanceof LoggerInterface) {
|
||||||
$this->Debugoutput->debug($str);
|
$this->Debugoutput->debug($str);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -930,7 +943,7 @@ protected function edebug($str)
|
|||||||
*
|
*
|
||||||
* @param bool $isHtml True for HTML mode
|
* @param bool $isHtml True for HTML mode
|
||||||
*/
|
*/
|
||||||
public function isHTML(bool $isHtml = true)
|
public function isHTML($isHtml = true)
|
||||||
{
|
{
|
||||||
if ($isHtml) {
|
if ($isHtml) {
|
||||||
$this->ContentType = static::CONTENT_TYPE_TEXT_HTML;
|
$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)
|
//Use the current punycode standard (appeared in PHP 7.2)
|
||||||
$punycode = idn_to_ascii(
|
$punycode = idn_to_ascii(
|
||||||
$domain,
|
$domain,
|
||||||
\IDNA_DEFAULT | \IDNA_USE_STD3_RULES | \IDNA_CHECK_BIDI |
|
IDNA_DEFAULT | IDNA_USE_STD3_RULES | IDNA_CHECK_BIDI |
|
||||||
\IDNA_CHECK_CONTEXTJ | \IDNA_NONTRANSITIONAL_TO_ASCII,
|
IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_ASCII,
|
||||||
\INTL_IDNA_VARIANT_UTS46
|
INTL_IDNA_VARIANT_UTS46
|
||||||
);
|
);
|
||||||
} elseif (defined('INTL_IDNA_VARIANT_2003')) {
|
} elseif (defined('INTL_IDNA_VARIANT_2003')) {
|
||||||
//Fall back to this old, deprecated/removed encoding
|
//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 {
|
} else {
|
||||||
//Fall back to a default we don't know about
|
//Fall back to a default we don't know about
|
||||||
$punycode = idn_to_ascii($domain, $errorcode);
|
$punycode = idn_to_ascii($domain, $errorcode);
|
||||||
@ -1522,7 +1535,7 @@ public function preSend()
|
|||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
'smtp' === $this->Mailer
|
'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
|
//SMTP mandates RFC-compliant line endings
|
||||||
//and it's also used with mail() on Windows
|
//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
|
//Check for buggy PHP versions that add a header with an incorrect line break
|
||||||
if (
|
if (
|
||||||
'mail' === $this->Mailer
|
'mail' === $this->Mailer
|
||||||
&& ((\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70017)
|
&& ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70017)
|
||||||
|| (\PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70103))
|
|| (PHP_VERSION_ID >= 70100 && PHP_VERSION_ID < 70103))
|
||||||
&& ini_get('mail.add_x_header') === '1'
|
&& ini_get('mail.add_x_header') === '1'
|
||||||
&& stripos(PHP_OS, 'WIN') === 0
|
&& stripos(PHP_OS, 'WIN') === 0
|
||||||
) {
|
) {
|
||||||
@ -1995,7 +2008,7 @@ public function setSMTPInstance(SMTP $smtp)
|
|||||||
*
|
*
|
||||||
* @see PHPMailer::setSMTPInstance() to use a different class.
|
* @see PHPMailer::setSMTPInstance() to use a different class.
|
||||||
*
|
*
|
||||||
* @uses \Mailer\PHPMailer\SMTP
|
* @uses SMTP
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function smtpSend($header, $body)
|
protected function smtpSend($header, $body)
|
||||||
@ -2080,7 +2093,7 @@ protected function smtpSend($header, $body)
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*
|
*
|
||||||
* @uses \Mailer\PHPMailer\SMTP
|
* @uses SMTP
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function smtpConnect($options = null)
|
public function smtpConnect($options = null)
|
||||||
@ -2767,7 +2780,7 @@ protected function generateId()
|
|||||||
if (function_exists('random_bytes')) {
|
if (function_exists('random_bytes')) {
|
||||||
try {
|
try {
|
||||||
$bytes = random_bytes($len);
|
$bytes = random_bytes($len);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
//Do nothing
|
//Do nothing
|
||||||
}
|
}
|
||||||
} elseif (function_exists('openssl_random_pseudo_bytes')) {
|
} elseif (function_exists('openssl_random_pseudo_bytes')) {
|
||||||
@ -4760,13 +4773,13 @@ public function DKIM_Sign($signHeader)
|
|||||||
$privKey = openssl_pkey_get_private($privKeyStr);
|
$privKey = openssl_pkey_get_private($privKeyStr);
|
||||||
}
|
}
|
||||||
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
|
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
|
||||||
if (\PHP_MAJOR_VERSION < 8) {
|
if (PHP_MAJOR_VERSION < 8) {
|
||||||
openssl_pkey_free($privKey);
|
openssl_pkey_free($privKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return base64_encode($signature);
|
return base64_encode($signature);
|
||||||
}
|
}
|
||||||
if (\PHP_MAJOR_VERSION < 8) {
|
if (PHP_MAJOR_VERSION < 8) {
|
||||||
openssl_pkey_free($privKey);
|
openssl_pkey_free($privKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||||
* https://www.x-lf.com/
|
* https://www.x-lf.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailer\PHPMailer;
|
namespace Mailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPMailer POP-Before-SMTP Authentication class.
|
* PHPMailer POP-Before-SMTP Authentication Class.
|
||||||
* Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
|
* Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
|
||||||
* 1) This class does not support APOP authentication.
|
* 1) This class does not support APOP authentication.
|
||||||
* 2) Opening and closing lots of POP3 connections can be quite slow. If you need
|
* 2) Opening and closing lots of POP3 connections can be quite slow. If you need
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||||
* https://www.x-lf.com/
|
* https://www.x-lf.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailer\PHPMailer;
|
namespace Mailer;
|
||||||
|
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPMailer RFC821 SMTP email transport class.
|
* PHPMailer RFC821 SMTP email transport class.
|
||||||
@ -131,7 +134,7 @@ class SMTP
|
|||||||
* $mail->Debugoutput = new myPsr3Logger;
|
* $mail->Debugoutput = new myPsr3Logger;
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @var string|callable|\Psr\Log\LoggerInterface
|
* @var string|callable|LoggerInterface
|
||||||
*/
|
*/
|
||||||
public $Debugoutput = 'echo';
|
public $Debugoutput = 'echo';
|
||||||
|
|
||||||
@ -253,7 +256,7 @@ protected function edebug($str, $level = 0)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Is this a PSR-3 logger?
|
//Is this a PSR-3 logger?
|
||||||
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
|
if ($this->Debugoutput instanceof LoggerInterface) {
|
||||||
$this->Debugoutput->debug($str);
|
$this->Debugoutput->debug($str);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user