aboutsummaryrefslogtreecommitdiff
path: root/lib/phpmailer
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-01-05 08:45:07 +0100
committerGravatar GitHub <noreply@github.com> 2024-01-05 08:45:07 +0100
commit4704c11d1770e024bea779a8500ee0b95b8479dc (patch)
tree2d4d5d94b3035e24d4cecfc2912dbf28f9afd292 /lib/phpmailer
parent889746cb10887ffc726c446214022ce9ffa75529 (diff)
Update to PHPMailer 6.9.1 (#6022)
Diffstat (limited to 'lib/phpmailer')
-rw-r--r--lib/phpmailer/phpmailer/.editorconfig15
-rw-r--r--lib/phpmailer/phpmailer/README.md5
-rw-r--r--lib/phpmailer/phpmailer/VERSION2
-rw-r--r--lib/phpmailer/phpmailer/src/PHPMailer.php130
-rw-r--r--lib/phpmailer/phpmailer/src/SMTP.php33
5 files changed, 179 insertions, 6 deletions
diff --git a/lib/phpmailer/phpmailer/.editorconfig b/lib/phpmailer/phpmailer/.editorconfig
new file mode 100644
index 000000000..a7c44ddb1
--- /dev/null
+++ b/lib/phpmailer/phpmailer/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+charset = utf-8
+indent_size = 4
+indent_style = space
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{yml,yaml}]
+indent_size = 2
diff --git a/lib/phpmailer/phpmailer/README.md b/lib/phpmailer/phpmailer/README.md
index 878274f48..e3e4ecff3 100644
--- a/lib/phpmailer/phpmailer/README.md
+++ b/lib/phpmailer/phpmailer/README.md
@@ -47,7 +47,7 @@ This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lg
PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file:
```json
-"phpmailer/phpmailer": "^6.8.1"
+"phpmailer/phpmailer": "^6.9.1"
```
or run
@@ -58,7 +58,8 @@ composer require phpmailer/phpmailer
Note that the `vendor` folder and the `vendor/autoload.php` script are generated by Composer; they are not part of PHPMailer.
-If you want to use the Gmail XOAUTH2 authentication class, you will also need to add a dependency on the `league/oauth2-client` package in your `composer.json`.
+If you want to use XOAUTH2 authentication, you will also need to add a dependency on the `league/oauth2-client` and appropriate service adapters package in your `composer.json`, or take a look at
+by @decomplexity's [SendOauth2 wrapper](https://github.com/decomplexity/SendOauth2), especially if you're using Microsoft services.
Alternatively, if you're not using Composer, you
can [download PHPMailer as a zip file](https://github.com/PHPMailer/PHPMailer/archive/master.zip), (note that docs and examples are not included in the zip file), then copy the contents of the PHPMailer folder into one of the `include_path` directories specified in your PHP configuration and load each class file manually:
diff --git a/lib/phpmailer/phpmailer/VERSION b/lib/phpmailer/phpmailer/VERSION
index 23863d3de..dc3829f5e 100644
--- a/lib/phpmailer/phpmailer/VERSION
+++ b/lib/phpmailer/phpmailer/VERSION
@@ -1 +1 @@
-6.8.1 \ No newline at end of file
+6.9.1
diff --git a/lib/phpmailer/phpmailer/src/PHPMailer.php b/lib/phpmailer/phpmailer/src/PHPMailer.php
index 7f56ea234..ba4bcd472 100644
--- a/lib/phpmailer/phpmailer/src/PHPMailer.php
+++ b/lib/phpmailer/phpmailer/src/PHPMailer.php
@@ -358,6 +358,13 @@ class PHPMailer
public $AuthType = '';
/**
+ * SMTP SMTPXClient command attibutes
+ *
+ * @var array
+ */
+ protected $SMTPXClient = [];
+
+ /**
* An implementation of the PHPMailer OAuthTokenProvider interface.
*
* @var OAuthTokenProvider
@@ -750,7 +757,7 @@ class PHPMailer
*
* @var string
*/
- const VERSION = '6.8.1';
+ const VERSION = '6.9.1';
/**
* Error severity: message only, continue processing.
@@ -1571,6 +1578,10 @@ class PHPMailer
//Validate From, Sender, and ConfirmReadingTo addresses
foreach (['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;
@@ -1998,6 +2009,38 @@ class PHPMailer
}
/**
+ * Provide SMTP XCLIENT attributes
+ *
+ * @param string $name Attribute name
+ * @param ?string $value Attribute value
+ *
+ * @return bool
+ */
+ 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;
+ }
+
+ /**
+ * Get SMTP XCLIENT attributes
+ *
+ * @return array
+ */
+ public function getSMTPXclientAttributes()
+ {
+ return $this->SMTPXClient;
+ }
+
+ /**
* Send mail via SMTP.
* Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
*
@@ -2025,6 +2068,9 @@ class PHPMailer
} 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);
@@ -2187,10 +2233,17 @@ class PHPMailer
$this->smtp->hello($hello);
//Automatically enable TLS encryption if:
//* it's not disabled
+ //* we are not connecting to localhost
//* we have openssl extension
//* we are not already using SSL
//* the server offers STARTTLS
- if ($this->SMTPAutoTLS && $sslext && 'ssl' !== $secure && $this->smtp->getServerExt('STARTTLS')) {
+ if (
+ $this->SMTPAutoTLS &&
+ $this->Host !== 'localhost' &&
+ $sslext &&
+ $secure !== 'ssl' &&
+ $this->smtp->getServerExt('STARTTLS')
+ ) {
$tls = true;
}
if ($tls) {
@@ -4048,6 +4101,79 @@ class PHPMailer
}
/**
+ * Clear a specific custom header by name or name and value.
+ * $name value can be overloaded to contain
+ * both header name and value (name:value).
+ *
+ * @param string $name Custom header name
+ * @param string|null $value Header value
+ *
+ * @return bool True if a header was replaced successfully
+ */
+ public function clearCustomHeader($name, $value = null)
+ {
+ if (null === $value && strpos($name, ':') !== false) {
+ //Value passed in as name:value
+ 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) {
+ // We remove the header if the value is not provided or it matches.
+ if (null === $value || $pair[1] == $value) {
+ unset($this->CustomHeader[$k]);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Replace a custom header.
+ * $name value can be overloaded to contain
+ * both header name and value (name:value).
+ *
+ * @param string $name Custom header name
+ * @param string|null $value Header value
+ *
+ * @return bool True if a header was replaced successfully
+ * @throws Exception
+ */
+ public function replaceCustomHeader($name, $value = null)
+ {
+ if (null === $value && strpos($name, ':') !== false) {
+ //Value passed in as name:value
+ 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, "\r\n") !== false) {
+ if ($this->exceptions) {
+ throw new Exception($this->lang('invalid_header'));
+ }
+
+ return false;
+ }
+ $this->CustomHeader[$k] = [$name, $value];
+ $replaced = true;
+ }
+ }
+
+ return true;
+ }
+
+ /**
* Add an error message to the error container.
*
* @param string $msg
diff --git a/lib/phpmailer/phpmailer/src/SMTP.php b/lib/phpmailer/phpmailer/src/SMTP.php
index 2b6384030..1b5b00771 100644
--- a/lib/phpmailer/phpmailer/src/SMTP.php
+++ b/lib/phpmailer/phpmailer/src/SMTP.php
@@ -35,7 +35,7 @@ class SMTP
*
* @var string
*/
- const VERSION = '6.8.1';
+ const VERSION = '6.9.1';
/**
* SMTP line break constant.
@@ -199,6 +199,18 @@ class SMTP
];
/**
+ * Allowed SMTP XCLIENT attributes.
+ * Must be allowed by the SMTP server. EHLO response is not checked.
+ *
+ * @see https://www.postfix.org/XCLIENT_README.html
+ *
+ * @var array
+ */
+ public static $xclient_allowed_attributes = [
+ 'NAME', 'ADDR', 'PORT', 'PROTO', 'HELO', 'LOGIN', 'DESTADDR', 'DESTPORT'
+ ];
+
+ /**
* The last transaction ID issued in response to a DATA command,
* if one was detected.
*
@@ -972,6 +984,25 @@ class SMTP
}
/**
+ * Send SMTP XCLIENT command to server and check its return code.
+ *
+ * @return bool True on success
+ */
+ public function xclient(array $vars)
+ {
+ $xclient_options = "";
+ foreach ($vars as $key => $value) {
+ if (in_array($key, SMTP::$xclient_allowed_attributes)) {
+ $xclient_options .= " {$key}={$value}";
+ }
+ }
+ if (!$xclient_options) {
+ return true;
+ }
+ return $this->sendCommand('XCLIENT', 'XCLIENT' . $xclient_options, 250);
+ }
+
+ /**
* Send an SMTP RSET command.
* Abort any transaction that is currently in progress.
* Implements RFC 821: RSET <CRLF>.