How to disable the order confirmation email?

In some projects, you may want to completely disable the order confirmation email sent when an order is completed. This guide explains two clean and recommended ways to do that:

✅ You can either:

  1. Disable the order_confirmation email configuration

  2. Disable the event listener responsible for sending it (OrderCompleteListener)


1. Disabling the Email via Configuration

This is the simplest and most future-proof approach.

Add or update your config/packages/sylius_mailer.yaml file:

# config/packages/sylius_mailer.yaml

sylius_mailer:
    emails:
        order_confirmation:
            enabled: false

With this, the order_confirmation email will be ignored by the mailer system, even if triggered.


2. Disabling the Listener (Advanced)

If you want to completely prevent the event logic that sends the email, disable the listener service itself.

Create a compiler pass:

<?php

// src/DependencyInjection/Compiler/DisableOrderConfirmationEmailPass.php

namespace App\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class DisableOrderConfirmationEmailPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container): void
    {
        $container->removeDefinition('sylius_shop.listener.order_complete');
    }
}

Then register the compiler pass in your Kernel:

<?php

// src/Kernel.php

namespace App;

use App\DependencyInjection\Compiler\DisableOrderConfirmationEmailPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

final class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    protected function build(ContainerBuilder $container): void
    {
        parent::build($container);
        $container->addCompilerPass(new DisableOrderConfirmationEmailPass());
    }
}

3. Verify the Listener is Removed

After clearing cache and rebuilding the container, use the Symfony commands to inspect attached listeners:

php bin/console debug:event sylius.order

This command lists all listeners attached to the sylius.order.* events.

To list all order related listeners, you can also use:

php bin/console debug:event-dispatcher | grep sylius.order

Which Option Should You Choose?

Use Case
Recommended Option

Stop the email, but keep the rest of the logic

✅ Option 1: Configuration

Disable all post-order-complete logic

⚠️ Option 2: Compiler Pass

Last updated

Was this helpful?