@@ -19,17 +19,26 @@ Installation
1919 Usage in Combination with the Mailer Component
2020----------------------------------------------
2121
22- When using a third-party mailer, you can use the Webhook component to receive
23- webhook calls from the third-party mailer .
22+ When using a third-party mailer provider , you can use the Webhook component to
23+ receive webhook calls from this provider .
2424
25- In this example Mailgun is used with ``'mailer_mailgun' `` as the webhook type.
26- Any type name can be used as long as it is unique. Make sure to use it in the
27- routing configuration, the webhook URL and the RemoteEvent consumer.
25+ Currently, the following third-party mailer providers support webhooks:
2826
29- Install the third-party mailer as described in the documentation of the
30- :ref: `Mailer component <mailer_3rd_party_transport >`.
27+ =============== ==========================================
28+ Mailer service Parser service name
29+ =============== ==========================================
30+ Mailgun ``mailer.webhook.request_parser.mailgun ``
31+ Postmark ``mailer.webhook.request_parser.postmark ``
32+ =============== ==========================================
33+
34+ .. note ::
35+
36+ Install the third-party mailer provider you want to use as described in the
37+ documentation of the :ref: `Mailer component <mailer_3rd_party_transport >`.
38+ Mailgun is used as the provider in this document as an example.
3139
32- The Webhook component routing needs to be defined:
40+ To connect the provider to your application, you need to configure the Webhook
41+ component routing:
3342
3443.. configuration-block ::
3544
@@ -77,27 +86,27 @@ The Webhook component routing needs to be defined:
7786 ;
7887 };
7988
80- Currently, the following third-party mailer services support webhooks:
89+ In this example, we are using ``mailer_mailgun `` as the webhook routing name.
90+ The routing name must be unique as this is what connects the provider with your
91+ webhook consumer code.
8192
82- =============== ==========================================
83- Mailer service Parser service name
84- =============== ==========================================
85- Mailgun ``mailer.webhook.request_parser.mailgun ``
86- Postmark ``mailer.webhook.request_parser.postmark ``
87- =============== ==========================================
88-
89- Set up the webhook in the third-party mailer. For Mailgun, you can do this
90- in the control panel. As URL, make sure to use the ``/webhook/mailer_mailgun ``
91- path behind the domain you're using.
93+ The webhook routing name is part of the URL you need to configure at the
94+ third-party mailer provider. The URL is the concatenation of your domain name
95+ and the routing name you chose in the configuration (like
96+ ``https://example.com/webhook/mailer_mailgun ``.
9297
93- Mailgun will provide a secret for the webhook. Add this secret to your ``.env ``
94- file:
98+ For Mailgun, you will get a secret for the webhook. Store this secret as
99+ MAILER_MAILGUN_SECRET (in the :doc: `secrets management system
100+ </configuration/secrets>` or in a ``.env `` file).
95101
96- .. code-block :: env
102+ When done, add a :class: `Symfony\\ Component\\ RemoteEvent\\ RemoteEvent ` consumer
103+ to react to incoming webhooks (the webhook routing name is what connects your
104+ class to the provider).
97105
98- MAILER_MAILGUN_SECRET=your_secret
99-
100- With this done, you can now add a RemoteEvent consumer to react to the webhooks::
106+ For mailer webhooks, react to the
107+ :class: `Symfony\\ Component\\ RemoteEvent\\ Event\\ Mailer\\ MailerDeliveryEvent ` or
108+ :class: `Symfony\\ Component\\ RemoteEvent\\ Event\\ Mailer\\ MailerEngagementEvent `
109+ events::
101110
102111 use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
103112 use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -145,12 +154,8 @@ SMS service Parser service name
145154Twilio ``notifier.webhook.request_parser.twilio ``
146155============ ==========================================
147156
148- .. versionadded :: 6.3
149-
150- The support for Twilio was introduced in Symfony 6.3.
151-
152- For SMS transports, an additional ``SmsEvent `` is available in the RemoteEvent
153- consumer::
157+ For SMS webhooks, react to the
158+ :class: `Symfony\\ Component\\ RemoteEvent\\ Event\\ Sms\\ SmsEvent ` event::
154159
155160 use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
156161 use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -165,13 +170,13 @@ consumer::
165170 if ($event instanceof SmsEvent) {
166171 $this->handleSmsEvent($event);
167172 } else {
168- // This is not an sms event
173+ // This is not an SMS event
169174 return;
170175 }
171176 }
172177
173178 private function handleSmsEvent(SmsEvent $event): void
174179 {
175- // Handle the sms event
180+ // Handle the SMS event
176181 }
177182 }
0 commit comments