0

After applying EmailMessageInterface_2.3.3_backward_compatibility_composer-2019-10-30-10-20-09.patch in Magento 2.3.3, getting below error in log files.

main.CRITICAL: Type Error occurred when creating object: Magento\Framework\Mail\EmailMessage, Argument 2 passed to Magento\Framework\Mail\EmailMessage::__construct() must be of the type array, null given, called in /var/www/html/m233/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 116 [] []

Please advise

1 Answer 1

0

this is a known core bug you can fix it with the following core patch.

Patch:

--- vendor/magento/framework/Mail/Template/TransportBuilder.php
+++ vendor/magento/framework/Mail/Template/TransportBuilder.php
@@ -377,6 +377,7 @@ protected function prepareMessage()
     {
         $template = $this->getTemplate();
         $content = $template->processTemplate();
+
         switch ($template->getType()) {
             case TemplateTypesInterface::TYPE_TEXT:
                 $part['type'] = MimeInterface::TYPE_TEXT;
@@ -391,7 +392,10 @@ protected function prepareMessage()
                     new Phrase('Unknown template type')
                 );
         }
+
+        /** @var \Magento\Framework\Mail\MimePartInterface $mimePart */
         $mimePart = $this->mimePartInterfaceFactory->create(['content' => $content]);
+        $this->messageData['encoding'] = $mimePart->getCharset();
         $this->messageData['body'] = $this->mimeMessageInterfaceFactory->create(
             ['parts' => [$mimePart]]
         );
@@ -400,6 +404,7 @@ protected function prepareMessage()
             (string)$template->getSubject(),
             ENT_QUOTES
         );
+
         $this->message = $this->emailMessageInterfaceFactory->create($this->messageData);

         return $this;

--- dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -769,7 +769,19 @@ public function testConfirmationEmailWithSpecialCharacters(): void
         $message = $this->transportBuilderMock->getSentMessage();
         $rawMessage = $message->getRawMessage();

-        $this->assertContains('To: John Smith <' . $email . '>', $rawMessage);
+        /** @var \Zend\Mime\Part $messageBodyPart */
+        $messageBodyParts = $message->getBody()->getParts();
+        $messageBodyPart = reset($messageBodyParts);
+        $messageEncoding = $messageBodyPart->getCharset();
+        $name = 'John Smith';
+
+        if (strtoupper($messageEncoding) !== 'ASCII') {
+            $name = \Zend\Mail\Header\HeaderWrap::mimeEncodeValue($name, $messageEncoding);
+        }
+
+        $nameEmail = sprintf('%s <%s>', $name, $email);
+
+        $this->assertContains('To: ' . $nameEmail, $rawMessage);

         $content = $message->getBody()->getParts()[0]->getRawContent();
         $confirmationUrl = $this->getConfirmationUrlFromMessageContent($content);

--- dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -783,7 +783,7 @@ public function testConfirmationEmailWithSpecialCharacters(): void

         $this->assertContains('To: ' . $nameEmail, $rawMessage);

-        $content = $message->getBody()->getParts()[0]->getRawContent();
+        $content = $messageBodyPart->getRawContent();
         $confirmationUrl = $this->getConfirmationUrlFromMessageContent($content);
         $this->setRequestInfo($confirmationUrl, 'confirm');
         $this->clearCookieMessagesList();

How to apply Patches on Magento 2

Isusses:

  1. https://github.com/magento/magento2/issues/24902
  2. https://github.com/magento/magento2/issues/25542

Best regards,

Lars

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.