skip to Main Content

After a customer tries to register with a special character in their name (accent), he/she receives the following message “We can’t save the customer.” and in debug.log I get the following errors:

[2020-01-02 12:11:19] main.CRITICAL: Exception message: Invalid header value detected
Trace: <pre>#1 ZendMailHeaderAbstractAddressList->getFieldValue(true) called at [vendor/zendframework/zend-mail/src/Header/AbstractAddressList.php:209]
#2 ZendMailHeaderAbstractAddressList->toString() called at [vendor/zendframework/zend-mail/src/Headers.php:427]
#3 ZendMailHeaders->toString() called at [vendor/zendframework/zend-mail/src/Message.php:546]
#4 ZendMailMessage->toString() called at [vendor/magento/framework/Mail/EmailMessage.php:217]
#5 MagentoFrameworkMailEmailMessage->toString() called at [vendor/magento/framework/Mail/EmailMessage.php:209]
#6 MagentoFrameworkMailEmailMessage->getRawMessage() called at [app/code/Mageplaza/Smtp/Mail/Transport.php:107]
#7 MageplazaSmtpMailTransport->aroundSendMessage(&MagentoEmailModelTransportInterceptor#0000000051b4369900000000733b30a0#, &Closure#0000000051b436f900000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#8 MagentoEmailModelTransportInterceptor->MagentoFrameworkInterception{closure}() called at [vendor/magento/module-email/Model/Mail/TransportInterfacePlugin.php:48]
#9 MagentoEmailModelMailTransportInterfacePlugin->aroundSendMessage(&MagentoEmailModelTransportInterceptor#0000000051b4369900000000733b30a0#, &Closure#0000000051b436f900000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#10 MagentoEmailModelTransportInterceptor->MagentoFrameworkInterception{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#11 MagentoEmailModelTransportInterceptor->___callPlugins('sendMessage', array(), NULL) called at [generated/code/Magento/Email/Model/Transport/Interceptor.php:26]
#12 MagentoEmailModelTransportInterceptor->sendMessage() called at [vendor/magento/module-customer/Model/EmailNotification.php:274]
#13 MagentoCustomerModelEmailNotification->sendEmailTemplate(&MagentoCustomerModelDataCustomer#0000000051b4362f00000000733b30a0#, 'customer/create_...', 'customer/create_...', array('customer' => &MagentoCustomerModelDataCustomerSecure#0000000051b434c000000000733b30a0#, 'back_url' => NULL, 'store' => &MagentoStoreModelStoreInterceptor#0000000051b435c400000000733b30a0#), 1) called at [vendor/magento/module-customer/Model/EmailNotification.php:398]
#14 MagentoCustomerModelEmailNotification->newAccount(&MagentoCustomerModelDataCustomer#0000000051b4362f00000000733b30a0#, 'registered', NULL, 1) called at [vendor/magento/module-customer/Model/AccountManagement.php:963]
#15 MagentoCustomerModelAccountManagement->sendEmailConfirmation(&MagentoCustomerModelDataCustomer#0000000051b4362f00000000733b30a0#, NULL) called at [vendor/magento/module-customer/Model/AccountManagement.php:921]
#16 MagentoCustomerModelAccountManagement->createAccountWithPasswordHash(&MagentoCustomerModelDataCustomer#0000000051b4362f00000000733b30a0#, '2a93ede7eb5cddf6...', NULL) called at [generated/code/Magento/Customer/Model/AccountManagement/Interceptor.php:141]
#17 MagentoCustomerModelAccountManagementInterceptor->createAccountWithPasswordHash(&MagentoCustomerModelDataCustomer#0000000051b434c500000000733b30a0#, '2a93ede7eb5cddf6...', NULL) called at [vendor/magento/module-customer/Model/AccountManagement.php:832]
#18 MagentoCustomerModelAccountManagement->createAccount(&MagentoCustomerModelDataCustomer#0000000051b434c500000000733b30a0#, 'HerrlichKraftvol...', NULL) called at [generated/code/Magento/Customer/Model/AccountManagement/Interceptor.php:128]
#19 MagentoCustomerModelAccountManagementInterceptor->createAccount(&MagentoCustomerModelDataCustomer#0000000051b434c500000000733b30a0#, 'HerrlichKraftvol...', NULL) called at [vendor/magento/module-customer/Controller/Account/CreatePost.php:353]
#20 MagentoCustomerControllerAccountCreatePost->execute() called at [generated/code/Magento/Customer/Controller/Account/CreatePost/Interceptor.php:50]
#21 MagentoCustomerControllerAccountCreatePostInterceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#22 MagentoFrameworkAppActionAction->dispatch(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#23 MagentoCustomerControllerAccountCreatePostInterceptor->___callParent('dispatch', array(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#24 MagentoCustomerControllerAccountCreatePostInterceptor->MagentoFrameworkInterception{closure}(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#25 MagentoCustomerControllerAccountCreatePostInterceptor->___callPlugins('dispatch', array(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#), array(array('designLoader', 'customerNotifica...', 'catalog_app_acti...', 'tax-app-action-d...', 'weee-app-action-...', 'customer_account', 'storeCheck', 'contextPlugin', 'customer-app-act...'), array('customer_account'))) called at [generated/code/Magento/Customer/Controller/Account/CreatePost/Interceptor.php:65]
#26 MagentoCustomerControllerAccountCreatePostInterceptor->dispatch(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/App/FrontController.php:159]
#27 MagentoFrameworkAppFrontController->processRequest(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#, &MagentoCustomerControllerAccountCreatePostInterceptor#0000000051b4333b00000000733b30a0#) called at [vendor/magento/framework/App/FrontController.php:99]
#28 MagentoFrameworkAppFrontController->dispatch(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#29 MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', array(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#30 MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94]
#31 MagentoStoreAppFrontControllerPluginRequestPreprocessor->aroundDispatch(&MagentoFrameworkAppFrontControllerInterceptor#0000000051b4317300000000733b30a0#, &Closure#0000000051b4315800000000733b30a0#, &MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#32 MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:73]
#33 MagentoPageCacheModelAppFrontControllerBuiltinPlugin->aroundDispatch(&MagentoFrameworkAppFrontControllerInterceptor#0000000051b4317300000000733b30a0#, &Closure#0000000051b4315800000000733b30a0#, &MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#34 MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#35 MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', array(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#), NULL) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#36 MagentoFrameworkAppFrontControllerInterceptor->dispatch(&MagentoFrameworkAppRequestHttp#0000000051b4309c00000000733b30a0#) called at [vendor/magento/framework/App/Http.php:137]
#37 MagentoFrameworkAppHttp->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#38 MagentoFrameworkAppHttpInterceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#39 MagentoFrameworkAppBootstrap->run(&MagentoFrameworkAppHttpInterceptor#0000000051b430f100000000733b30a0#) called at [index.php:39]

We already tried updating Zend, but this did not resolve the issue.

2

Answers


  1. 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.

    This is a modified path

    vendormagentoframeworkMailEmailMessage.php

    Please replace function with this :

    public function toString(): string
        {
            $this->message->setEncoding('utf-8');
            return $this->message->toString();
        }
    
    Login or Signup to reply.
  2. In vendor/magento/framework/Mail/Template/TransportBuilder.php find the function prepareMessage(), find the below line

    $this->message = $this->emailMessageInterfaceFactory->create($this->messageData);
    

    and add this line before it:

    $this->messageData['encoding'] = $mimePart->getCharset();
    

    So it looks something like

    $this->messageData['encoding'] = $mimePart->getCharset();
    $this->message = $this->emailMessageInterfaceFactory->create($this->messageData);
    
    return $this;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search