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:
Disable the
order_confirmationemail configurationDisable 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: falseWith this, the order_confirmation email will be ignored by the mailer system, even if triggered.
After making this change, make sure to clear the cache for the configuration to take effect:
php bin/console cache:clear2. 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:
Then register the compiler pass in your Kernel:
Kernel:Use this method only if you are sure you want to completely prevent any logic in the listener, not just the email.
3. Verify the Listener is Removed
After clearing cache and rebuilding the container, use the Symfony commands to inspect attached listeners:
This command lists all listeners attached to the sylius.order.* events.
If the OrderCompleteListener is still listed (usually from Sylius\Component\Core\EventListener\OrderCompleteListener), the removal didn't work β recheck your compiler pass and cache.
To list all order related listeners, you can also use:
This helps you spot additional event listeners tied to Sylius resource lifecycle events (e.g. sylius.order.post_create, sylius.order.pre_update, etc.).
Which Option Should You Choose?
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?
