@@ -15,17 +15,26 @@ Installation
1515 Usage in Combination with the Mailer Component
1616----------------------------------------------
1717
18- When using a third-party mailer, you can use the Webhook component to receive
19- webhook calls from the third-party mailer .
18+ When using a third-party mailer provider , you can use the Webhook component to
19+ receive webhook calls from this provider .
2020
21- In this example Mailgun is used with ``'mailer_mailgun' `` as the webhook type.
22- Any type name can be used as long as it is unique. Make sure to use it in the
23- routing configuration, the webhook URL and the RemoteEvent consumer.
21+ Currently, the following third-party mailer providers support webhooks:
2422
25- Install the third-party mailer as described in the documentation of the
26- :ref: `Mailer component <mailer_3rd_party_transport >`.
23+ =============== ==========================================
24+ Mailer service Parser service name
25+ =============== ==========================================
26+ Mailgun ``mailer.webhook.request_parser.mailgun ``
27+ Postmark ``mailer.webhook.request_parser.postmark ``
28+ =============== ==========================================
2729
28- The Webhook component routing needs to be defined:
30+ .. note ::
31+
32+ Install the third-party mailer provider you want to use as described in the
33+ documentation of the :ref: `Mailer component <mailer_3rd_party_transport >`.
34+ Mailgun is used as the provider in this document as an example.
35+
36+ To connect the provider to your application, you need to configure the Webhook
37+ component routing:
2938
3039.. configuration-block ::
3140
@@ -73,30 +82,27 @@ The Webhook component routing needs to be defined:
7382 ;
7483 };
7584
76- Currently, the following third-party services support webhooks:
77-
78- ============== ==========================================
79- Mailer Service Parser service name
80- ============== ==========================================
81- Brevo ``mailer.webhook.request_parser.brevo ``
82- Mailgun ``mailer.webhook.request_parser.mailgun ``
83- Mailjet ``mailer.webhook.request_parser.mailjet ``
84- Postmark ``mailer.webhook.request_parser.postmark ``
85- Sendgrid ``mailer.webhook.request_parser.sendgrid ``
86- ============== ==========================================
87-
88- Set up the webhook in the third-party mailer. For Mailgun, you can do this
89- in the control panel. As URL, make sure to use the ``/webhook/mailer_mailgun ``
90- path behind the domain you're using.
85+ In this example, we are using ``mailer_mailgun `` as the webhook routing name.
86+ The routing name must be unique as this is what connects the provider with your
87+ webhook consumer code.
9188
92- Mailgun will provide a secret for the webhook. Add this secret to your ``.env ``
93- file:
89+ The webhook routing name is part of the URL you need to configure at the
90+ third-party mailer provider. The URL is the concatenation of your domain name
91+ and the routing name you chose in the configuration (like
92+ ``https://example.com/webhook/mailer_mailgun ``.
9493
95- .. code-block :: env
94+ For Mailgun, you will get a secret for the webhook. Store this secret as
95+ MAILER_MAILGUN_SECRET (in the :doc: `secrets management system
96+ </configuration/secrets>` or in a ``.env `` file).
9697
97- MAILER_MAILGUN_SECRET=your_secret
98+ When done, add a :class: `Symfony\\ Component\\ RemoteEvent\\ RemoteEvent ` consumer
99+ to react to incoming webhooks (the webhook routing name is what connects your
100+ class to the provider).
98101
99- With this done, you can now add a RemoteEvent consumer to react to the webhooks::
102+ For mailer webhooks, react to the
103+ :class: `Symfony\\ Component\\ RemoteEvent\\ Event\\ Mailer\\ MailerDeliveryEvent ` or
104+ :class: `Symfony\\ Component\\ RemoteEvent\\ Event\\ Mailer\\ MailerEngagementEvent `
105+ events::
100106
101107 use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
102108 use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -145,8 +151,8 @@ Twilio ``notifier.webhook.request_parser.twilio``
145151Vonage ``notifier.webhook.request_parser.vonage ``
146152============ ==========================================
147153
148- For SMS transports, an additional `` SmsEvent `` is available in the RemoteEvent
149- consumer ::
154+ For SMS webhooks, react to the
155+ :class: ` Symfony \\ Component \\ RemoteEvent \\ Event \\ Sms \\ SmsEvent ` event ::
150156
151157 use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
152158 use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -161,13 +167,13 @@ consumer::
161167 if ($event instanceof SmsEvent) {
162168 $this->handleSmsEvent($event);
163169 } else {
164- // This is not an sms event
170+ // This is not an SMS event
165171 return;
166172 }
167173 }
168174
169175 private function handleSmsEvent(SmsEvent $event): void
170176 {
171- // Handle the sms event
177+ // Handle the SMS event
172178 }
173179 }
0 commit comments