@@ -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
+ =============== ==========================================
31
33
32
- The Webhook component routing needs to be defined:
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.
39
+
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,38 +86,27 @@ The Webhook component routing needs to be defined:
77
86
;
78
87
};
79
88
80
- Currently, the following third-party services support webhooks:
81
-
82
- ============== ==========================================
83
- Mailer Service Parser service name
84
- ============== ==========================================
85
- Brevo ``mailer.webhook.request_parser.brevo ``
86
- Mailgun ``mailer.webhook.request_parser.mailgun ``
87
- Mailjet ``mailer.webhook.request_parser.mailjet ``
88
- Postmark ``mailer.webhook.request_parser.postmark ``
89
- Sendgrid ``mailer.webhook.request_parser.sendgrid ``
90
- ============== ==========================================
91
-
92
- .. versionadded :: 6.3
93
-
94
- The support for Mailgun and Postmark was introduced in Symfony 6.3.
95
-
96
- .. versionadded :: 6.4
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.
97
92
98
- The support for Brevo, Mailjet and Sendgrid was introduced in Symfony 6.4.
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 ``.
99
97
100
- Set up the webhook in the third-party mailer. For Mailgun, you can do this
101
- in the control panel. As URL, make sure to use the `` /webhook/mailer_mailgun ``
102
- path behind the domain you're using .
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) .
103
101
104
- Mailgun will provide a secret for the webhook. Add this secret to your ``.env ``
105
- file:
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).
106
105
107
- .. code-block :: env
108
-
109
- MAILER_MAILGUN_SECRET=your_secret
110
-
111
- 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::
112
110
113
111
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
114
112
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -157,16 +155,8 @@ Twilio ``notifier.webhook.request_parser.twilio``
157
155
Vonage ``notifier.webhook.request_parser.vonage ``
158
156
============ ==========================================
159
157
160
- .. versionadded :: 6.3
161
-
162
- The support for Twilio was introduced in Symfony 6.3.
163
-
164
- .. versionadded :: 6.4
165
-
166
- The support for Vonage was introduced in Symfony 6.4.
167
-
168
- For SMS transports, an additional ``SmsEvent `` is available in the RemoteEvent
169
- consumer::
158
+ For SMS webhooks, react to the
159
+ :class: `Symfony\\ Component\\ RemoteEvent\\ Event\\ Sms\\ SmsEvent ` event::
170
160
171
161
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
172
162
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
@@ -181,13 +171,13 @@ consumer::
181
171
if ($event instanceof SmsEvent) {
182
172
$this->handleSmsEvent($event);
183
173
} else {
184
- // This is not an sms event
174
+ // This is not an SMS event
185
175
return;
186
176
}
187
177
}
188
178
189
179
private function handleSmsEvent(SmsEvent $event): void
190
180
{
191
- // Handle the sms event
181
+ // Handle the SMS event
192
182
}
193
183
}
0 commit comments