Merge pull request #9242 from nupplaphil/bug/9142-message-id

Transform email header string to header array
This commit is contained in:
Hypolite Petovan 2020-09-19 22:10:20 -04:00 committed by GitHub
commit 722aada460
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 74 additions and 28 deletions

View file

@ -83,11 +83,18 @@ interface IEmail extends JsonSerializable
function getMessage(bool $plain = false);
/**
* Gets any additional mail header
* Gets the additional mail header array
*
* @return string[][]
*/
function getAdditionalMailHeader();
/**
* Gets the additional mail header as string - EOL separated
*
* @return string
*/
function getAdditionalMailHeader();
function getAdditionalMailHeaderString();
/**
* Returns the current email with a new recipient

View file

@ -47,14 +47,14 @@ class Email implements IEmail
/** @var string */
private $msgText;
/** @var string */
private $additionalMailHeader = '';
/** @var string[][] */
private $additionalMailHeader;
/** @var int|null */
private $toUid = null;
private $toUid;
public function __construct(string $fromName, string $fromAddress, string $replyTo, string $toAddress,
string $subject, string $msgHtml, string $msgText,
string $additionalMailHeader = '', int $toUid = null)
array $additionalMailHeader = [], int $toUid = null)
{
$this->fromName = $fromName;
$this->fromAddress = $fromAddress;
@ -127,6 +127,25 @@ class Email implements IEmail
return $this->additionalMailHeader;
}
/**
* {@inheritDoc}
*/
public function getAdditionalMailHeaderString()
{
$headerString = '';
foreach ($this->additionalMailHeader as $name => $values) {
if (is_array($values)) {
foreach ($values as $value) {
$headerString .= $name . ': ' . $value . '\n';
}
} else {
$headerString .= $name . ': ' . $values . '\n';
}
}
return $headerString;
}
/**
* {@inheritDoc}
*/