|
|
@@ -242,6 +242,27 @@ class Email implements JsonSerializable, Serializable
|
|
|
public $headerCharset;
|
|
|
|
|
|
/**
|
|
|
+ * The email transfer encoding used.
|
|
|
+ * If null, the $charset property is used for determined the transfer encoding.
|
|
|
+ *
|
|
|
+ * @var string|null
|
|
|
+ */
|
|
|
+ protected $transferEncoding;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Available encoding to be set for transfer.
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ protected $_transferEncodingAvailable = [
|
|
|
+ '7bit',
|
|
|
+ '8bit',
|
|
|
+ 'base64',
|
|
|
+ 'binary',
|
|
|
+ 'quoted-printable'
|
|
|
+ ];
|
|
|
+
|
|
|
+ /**
|
|
|
* The application wide charset, used to encode headers and body
|
|
|
*
|
|
|
* @var string|null
|
|
|
@@ -844,6 +865,38 @@ class Email implements JsonSerializable, Serializable
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * TransferEncoding setter.
|
|
|
+ *
|
|
|
+ * @param string|null $encoding Encoding set.
|
|
|
+ * @return $this
|
|
|
+ */
|
|
|
+ public function setTransferEncoding($encoding)
|
|
|
+ {
|
|
|
+ $encoding = strtolower($encoding);
|
|
|
+ if (!in_array($encoding, $this->_transferEncodingAvailable)) {
|
|
|
+ throw new InvalidArgumentException(
|
|
|
+ sprintf(
|
|
|
+ 'Transfer encoding not available. Can be : %s.',
|
|
|
+ implode(', ', $this->_transferEncodingAvailable)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $this->transferEncoding = $encoding;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * TransferEncoding getter.
|
|
|
+ *
|
|
|
+ * @return string|null Encoding
|
|
|
+ */
|
|
|
+ public function getTransferEncoding()
|
|
|
+ {
|
|
|
+ return $this->transferEncoding;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* EmailPattern setter/getter
|
|
|
*
|
|
|
* @param string|null $regex The pattern to use for email address validation,
|
|
|
@@ -2268,6 +2321,7 @@ class Email implements JsonSerializable, Serializable
|
|
|
$this->_priority = null;
|
|
|
$this->charset = 'utf-8';
|
|
|
$this->headerCharset = null;
|
|
|
+ $this->transferEncoding = null;
|
|
|
$this->_attachments = [];
|
|
|
$this->_profile = [];
|
|
|
$this->_emailPattern = self::EMAIL_PATTERN;
|
|
|
@@ -2699,12 +2753,17 @@ class Email implements JsonSerializable, Serializable
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Return the Content-Transfer Encoding value based on the set charset
|
|
|
+ * Return the Content-Transfer Encoding value based
|
|
|
+ * on the set transferEncoding or set charset.
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
protected function _getContentTransferEncoding()
|
|
|
{
|
|
|
+ if ($this->transferEncoding) {
|
|
|
+ return $this->transferEncoding;
|
|
|
+ }
|
|
|
+
|
|
|
$charset = strtoupper($this->charset);
|
|
|
if (in_array($charset, $this->_charset8bit)) {
|
|
|
return '8bit';
|