Showing results for 
Search instead for 
Did you mean: 

Upgrade results in order Confirmation emails not working

Upgrade results in order Confirmation emails not working



I recently upgraded from 2.4.2 to 2.4.5-p1 and my email order confirmations no longer work. 


My variables were all in the format {{var order.getBillingAddress().format('html')}}


but now they are like this {{var formattedBillingAddress|raw}}

In my previous order confirmations I would include the customer email address just below the billing address using:

{{var order.getCustomerEmail()}}


But this no longer works with 2.4.5


This is something that changed with 2.4.4 


Anyone know what the variable for customer email under the new system?  


I looked around and tried a few things, but nothing worked.





Re: Upgrade results in order Confirmation emails not working

{{var order_data.customer_email}}

What about that?

Re: Upgrade results in order Confirmation emails not working

Hi @racicot6977e3e ,

Create events.xml file on app/code/Vendor/Module/etc

<?xml version="1.0" ?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="email_order_set_template_vars_before">
<observer instance="Vendor\Module\Observer\Email\OrderSetTemplateVarsBefore" name="v4u_emailvar_observer_email_ordersettemplatevarsbefore_email_order_set_template_vars_before"/>

Create OrderSetTemplateVarsBefore.php on app/code/Vendor/Module/Observer/Email

* Copyright © All rights reserved.
* See COPYING.txt for license details.

namespace Vendor\Module\Observer\Email;

use Magento\Customer\Api\CustomerRepositoryInterface;

class OrderSetTemplateVarsBefore implements \Magento\Framework\Event\ObserverInterface

protected $customerRepository;

public function __construct(
CustomerRepositoryInterface $customerRepository
) {
$this->customerRepository = $customerRepository;

* Execute observer
* @param \Magento\Framework\Event\Observer $observer
* @return void
public function execute(
\Magento\Framework\Event\Observer $observer
) {

/** @var \Magento\Framework\App\Action\Action $controller */
$transport = $observer->getEvent()->getTransport();
if($transport->getOrder() != null)
$customer = $this->customerRepository->getById($transport->getOrder()->getCustomerId());
$transport['customer_email'] = $customer->getEmail();

Email Template you can use it like below:

{{var customer_email}}

Problem Solved? Accept as Solution!

Ankit Jasani

Re: Upgrade results in order Confirmation emails not working

No this didn't work.


The email address was blank on the order confirmation. 



Thanks for trying...

Re: Upgrade results in order Confirmation emails not working

Hello racicot6977e3e,


When an order is made, online stores must automatically send a sales email or order confirmation to their customers, which is done via configuration in Magento 2. But, If you're facing order Confirmation emails not working problem after the upgrade, you can follow the below ways to fix the issue,


Check the configuration on the admin page:

  • Firstly, navigate to System > Configuration Advanced System Mail Sending option.
  • Then, disable the Email Communications options, and choose No.


Check server configuration:

  • You must try executing the following code,


mail ('', "Test Postfix", "Test mail from postfix");

Note: You will have to enter your email address in place of ''


You need to check the server settings if you don't receive any emails using the above code.


You must check the Var/log to find any warning or error related to mail, and check the following configuration:


  • Navigate to Stores > Configuration > Advanced > System
  • Under Mail Sending Settings, ensure -  Disable Email Communications is set to No.

Also, verify your Host and Port fields, If using any external mailing server.

  • Now, navigate to Stores > Configuration > Sales > Sales Emails
  • Then, under the general Settings tab, choose Asynchronous sending to Disable.
  • Next, under the Order tab, Enabled to Yes.
  • Lastly, clear/refresh your magento cache.


If the issue persists, you must ensure your cronjob setup on your hosting panel or server is running, as it might be causing email delays. In addition, you must also check your payment gateways once, as it can also cause the "order Confirmation emails not working" problem.


Thus, I hope the above solution helps you fix the "order Confirmation emails not working after upgrade" issue.




Rex M

Magento Hosting | VPS Hosting