Bug #100016
closed"X-Mailer: TYPO3" will be set many times
100%
Description
We're using a code like this:
/** @var MailMessage $email */
$this->email = GeneralUtility::makeInstance(MailMessage::class);
foreach ($recipientChunk as $recipient){
$this->email
->to($recipient->getEmail())
->from($newsletter->getSender())
->replyTo($newsletter->getReplyTo())
->subject($newsletter->getSubject());
...
...
...
$this->email
->html($htmlContent)
->text($textContent);
...
...
$this->email->send();
}
We're trying to instantiate as less as possible, so the MailMessage-Object is reused.
The problem is that the core (Mailer.php) does this:
public function send(RawMessage $message, Envelope $envelope = null): void
{
...
$message->getHeaders()->addTextHeader('X-Mailer', $this->mailerHeader);
With each mail in the loop there will be a new "'X-Mailer: TYPO3" added.
We're having a loop with hundreds of recipients, so the header will get to large:
Reporting-MTA: dns; mgmt.***.backend Diagnostic-Code: smtp; 552 5.6.0 Headers too large (32768 max)
It would better to check if the header ist set before:
$headers = $message->getHeaders();
if (! $headers->has('X-Mailer')){
$headers->addTextHeader('X-Mailer', $this->mailerHeader);
}
or
$headers = $message->getHeaders();
if (! $headers->has('X-Mailer')){
$header->remove('X-Mailer');
}
$headers->addTextHeader('X-Mailer', $this->mailerHeader);
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77934
Updated by Gerrit Code Review over 1 year ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77934
Updated by Thomas Hohn over 1 year ago
- Target version set to Candidate for patchlevel
Updated by Gerrit Code Review over 1 year ago
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77953
Updated by Thomas Hohn over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 10cbd42b3f67717e842233ddf8a6cb7a9af6af78.