I am showing these errors in my system log while requesting a password reset, and the customer don't receive the email.

[2020-01-09 05:16:28] main.CRITICAL: Exception message: Invalid header value detected
Trace: <pre>#1 Zend\Mail\Header\AbstractAddressList->getFieldValue(true) called at [vendor/zendframework/zend-mail/src/Header/AbstractAddressList.php:209]
#2 Zend\Mail\Header\AbstractAddressList->toString() called at [vendor/zendframework/zend-mail/src/Headers.php:426]
#3 Zend\Mail\Headers->toString() called at [vendor/zendframework/zend-mail/src/Message.php:546]
#4 Zend\Mail\Message->toString() called at [vendor/magento/framework/Mail/EmailMessage.php:217]
#5 Magento\Framework\Mail\EmailMessage->toString() called at [vendor/magento/framework/Mail/EmailMessage.php:209]

Yes, it is a bug with encoding ...

In the EmailMessage class (vendor/magento/framework/Mail/EmailMessage.php) the encoding can be set if passed in an argument in the constructor, but it is null by default.

if ($encoding) {

So, I think the best practice use type in di.xml in your module without rewrite and plugins

<type name="Magento\Framework\Mail\EmailMessage">
       <argument name="encoding" xsi:type="string">utf-8</argument>

This is a bug of Magento version 2.3.3. It does not allow the use of special characters such as ã, ơ in-store email address or sender mail name or etc...

This is a changed path in Magento


Please replace function with this code in above file :

public function toString(): string {
    return $this->message->toString();
  • Thank you, works like a charm in Magento 2.3.3. Sep 26 '20 at 7:54
  • It seems that in magento 2.4 this changed, do you know what the solution for 2.4 looks like? Jun 21 '21 at 1:45
  • Yeah! also worked for me. EmailMessage.php file, line 215 in my case. Thanks all. Aug 4 '21 at 15:23

Here is the class in case some one wonders what is going on:

class SenderBuilder extends \Magento\Sales\Model\Order\Email\SenderBuilder
     * @throws \Magento\Framework\Exception\LocalizedException
     * @throws \Magento\Framework\Exception\MailException
    public function send()
        //Removed Customer name because of diacritics

        $copyTo = $this->identityContainer->getEmailCopyTo();
        if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc') {
            foreach ($copyTo as $email) {

        $transport = $this->transportBuilder->getTransport();

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.