We would like to use a custom mailbox for all transactional emails sent by the store. Sometimes a customer replies to f.e. an order confirmation email and this email then also is sent to this mailbox.
As this mailbox is not checked regularly we would like to add a reply-to-email to all transactional emails. This is not possible out-of-the-box in Magento 2.4. Is there a solution how to add it programmatically to all transactional emails?

1 Answer 1


To add a reply-to email address programmatically for all transactional emails in Magento 2.4, you can create a custom module to extend the email functionality. Follow these steps to create the module:

Create a new folder for the custom module in app/code. Name it according to your company name and module name, such as CompanyName/CustomReplyTo.

In the new module folder, create these subdirectories: etc and Plugin.

Create a module.xml file in the etc directory and add the following content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="CompanyName_CustomReplyTo" setup_version="1.0.0">
            <module name="Magento_Email"/>

Create a di.xml file in the etc directory and add the following content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\Mail\Template\TransportBuilder">
        <plugin name="customReplyToPlugin" type="CompanyName\CustomReplyTo\Plugin\TransportBuilderPlugin" sortOrder="10"/>

Create a TransportBuilderPlugin.php file in the Plugin directory and add the following content:

namespace CompanyName\CustomReplyTo\Plugin;

use Magento\Framework\Mail\Template\TransportBuilder;

class TransportBuilderPlugin
    public function aroundSetTemplateVars(
        TransportBuilder $subject,
        \Closure $proceed,
        array $templateVars
    ) {
        // Set the custom reply-to email address.
        $replyToEmail = '[email protected]';
        if ($replyToEmail) {
        return $proceed($templateVars);

Replace 'your_reply[email protected]' with your desired reply-to email address.

Enable the module by running the following command in your Magento root directory:

bin/magento module:enable CompanyName_CustomReplyTo

Update the Magento system: (Keep Calm)

bin/magento setup:upgrade
bin/magento cache:clean

After completing these steps, your custom module should be installed and active. It will automatically set the reply-to email address for all transactional emails sent by your Magento store.

  • 1
    Many thanks, awesome! works like a charm! Apr 26 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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