Project

General

Profile

Actions

Bug #100016

closed

"X-Mailer: TYPO3" will be set many times

Added by Ralph Brugger over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Mailer API
Start date:
2023-02-23
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

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);

Actions #1

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

Actions #2

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

Actions #3

Updated by Thomas Hohn over 1 year ago

  • Target version set to Candidate for patchlevel
Actions #4

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

Actions #5

Updated by Thomas Hohn over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #6

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF