@@ -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,35 +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- Resend ``mailer.webhook.request_parser.resend ``
86- Sendgrid ``mailer.webhook.request_parser.sendgrid ``
87- ============== ==========================================
88-
89- .. versionadded :: 7.1
90-
91- The Resend webhook was introduced in Symfony 7.1.
92-
93- Set up the webhook in the third-party mailer. For Mailgun, you can do this
94- in the control panel. As URL, make sure to use the ``/webhook/mailer_mailgun ``
95- 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.
9688
97- Mailgun will provide a secret for the webhook. Add this secret to your ``.env ``
98- 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 ``.
9993
100- .. 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).
10197
102- 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).
103101
104- 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::
105106
106107 use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
107108 use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -150,8 +151,8 @@ Twilio ``notifier.webhook.request_parser.twilio``
150151Vonage ``notifier.webhook.request_parser.vonage ``
151152============ ==========================================
152153
153- For SMS transports, an additional `` SmsEvent `` is available in the RemoteEvent
154- consumer ::
154+ For SMS webhooks, react to the
155+ :class: ` Symfony \\ Component \\ RemoteEvent \\ Event \\ Sms \\ SmsEvent ` event ::
155156
156157 use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
157158 use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -166,13 +167,13 @@ consumer::
166167 if ($event instanceof SmsEvent) {
167168 $this->handleSmsEvent($event);
168169 } else {
169- // This is not an sms event
170+ // This is not an SMS event
170171 return;
171172 }
172173 }
173174
174175 private function handleSmsEvent(SmsEvent $event): void
175176 {
176- // Handle the sms event
177+ // Handle the SMS event
177178 }
178179 }
0 commit comments