How to Add a Reply-To Address for a Contact Form in Shopware
When customers submit inquiries using the default Shopware contact form, the admin receives the email but cannot reply directly. This is because the ‘To’ address is set to the admin’s email, preventing a quick response to customer queries. This article explains how to resolve this issue by creating a custom plugin that overrides the MailBeforeValidateEvent subscriber.
Problem: Cannot Reply Directly to Customers
By default, when a customer submits a request via the Shopware contact form, the email is sent to the store admin. However, since the email is from the store itself, replying does not send a response to the customer’s email address.
Solution: Override MailBeforeValidateEvent
To allow the admin to reply directly to customers, you need to create a custom plugin and override the MailBeforeValidateEvent subscriber. Follow these steps:
1. Create a Custom Subscriber
Create a new subscriber file and implement the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <?php namespace ContactFormReplyTo\Subscriber; use Shopware\Core\Content\MailTemplate\Service\Event\MailBeforeValidateEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class ContactFormSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents(): array { return [ MailBeforeValidateEvent::class => 'onMailBeforeValidate' ]; } public function onMailBeforeValidate(MailBeforeValidateEvent $event): void { $data = $event->getData(); $templateData = $event->getTemplateData(); if ($templateData['eventName'] == 'contact_form.send') { if (isset($templateData['contactFormData'])) { $contactFormData = $templateData['contactFormData']; if (isset($contactFormData['email'])) { $data['replyTo'] = $contactFormData['email']; $event->setData($data); } } } } } |
2. Register the Subscriber in services.xml
Add the following configuration in services.xml to register the subscriber:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <service id="ContactFormReplyTo\Subscriber\ContactFormSubscriber"> <tag name="kernel.event_subscriber"/> </service> </services> </container> |
Conclusion
By implementing this custom plugin, Shopware admins can now reply directly to customer inquiries submitted through the contact form. This simple override improves communication efficiency and ensures better customer service.
For further support, contact 2Hats Logic.
Recent help desk articles

Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
