@@ -19,17 +19,26 @@ Installation
19
19
Usage in Combination with the Mailer Component
20
20
----------------------------------------------
21
21
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 .
24
24
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:
28
26
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.
31
39
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:
33
42
34
43
.. configuration-block ::
35
44
@@ -77,27 +86,27 @@ The Webhook component routing needs to be defined:
77
86
;
78
87
};
79
88
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.
81
92
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 ``.
92
97
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).
95
101
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).
97
105
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::
101
110
102
111
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
103
112
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -145,12 +154,8 @@ SMS service Parser service name
145
154
Twilio ``notifier.webhook.request_parser.twilio ``
146
155
============ ==========================================
147
156
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::
154
159
155
160
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
156
161
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -165,13 +170,13 @@ consumer::
165
170
if ($event instanceof SmsEvent) {
166
171
$this->handleSmsEvent($event);
167
172
} else {
168
- // This is not an sms event
173
+ // This is not an SMS event
169
174
return;
170
175
}
171
176
}
172
177
173
178
private function handleSmsEvent(SmsEvent $event): void
174
179
{
175
- // Handle the sms event
180
+ // Handle the SMS event
176
181
}
177
182
}
0 commit comments