1
0
Fork 0

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

@ -49,7 +49,7 @@ abstract class MailBuilder
/** @var LoggerInterface */
protected $logger;
/** @var string */
/** @var string[][] */
protected $headers;
/** @var string */
@ -76,13 +76,14 @@ abstract class MailBuilder
$hostname = substr($hostname, 0, strpos($hostname, ':'));
}
$this->headers = "";
$this->headers .= "Precedence: list\n";
$this->headers .= "X-Friendica-Host: " . $hostname . "\n";
$this->headers .= "X-Friendica-Platform: " . FRIENDICA_PLATFORM . "\n";
$this->headers .= "X-Friendica-Version: " . FRIENDICA_VERSION . "\n";
$this->headers .= "List-ID: <notification." . $hostname . ">\n";
$this->headers .= "List-Archive: <" . $baseUrl->get() . "/notifications/system>\n";
$this->headers = [
'Precedence' => ['list'],
'X-Friendica-Host' => [$hostname],
'X-Friendica-Platform' => [FRIENDICA_PLATFORM],
'X-Friendica-Version' => [FRIENDICA_VERSION],
'List-ID' => ['<notification.' . $hostname . '>'],
'List-Archive' => ['<' . $baseUrl->get() . '/notifications/system>'],
];
}
/**
@ -159,15 +160,31 @@ abstract class MailBuilder
}
/**
* Adds new headers to the default headers
* Adds a value to a header
*
* @param string $headers New headers
* @param string $name The header name
* @param string $value The value of the header to add
*
* @return static
*/
public function addHeaders(string $headers)
public function addHeader(string $name, string $value)
{
$this->headers .= $headers;
$this->headers[$name][] = $value;
return $this;
}
/**
* Sets a value to a header (overwrites existing values)
*
* @param string $name The header name
* @param string $value The value to set
*
* @return static
*/
public function setHeader(string $name, string $value)
{
$this->headers[$name] = [$value];
return $this;
}

View file

@ -151,7 +151,7 @@ class Emailer
. rand(10000, 99999);
// generate a multipart/alternative message header
$messageHeader = $email->getAdditionalMailHeader() .
$messageHeader = $email->getAdditionalMailHeaderString() .
"From: $fromName <{$fromAddress}>\n" .
"Reply-To: $fromName <{$replyTo}>\n" .
"MIME-Version: 1.0\n" .