Skip to content

Commit 85de55b

Browse files
committed
[Mailer] [Mailgun] Fix payload converter getReason
1 parent 7e6931c commit 85de55b

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

src/Symfony/Component/Mailer/Bridge/Mailgun/RemoteEvent/MailgunPayloadConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function matchFailedEvent(array $payload): string
7575

7676
private function getReason(array $payload): string
7777
{
78-
if ('' !== $payload['delivery-status']['description']) {
78+
if ('' !== ($payload['delivery-status']['description'] ?? '')) {
7979
return $payload['delivery-status']['description'];
8080
}
8181
if ('' !== $payload['delivery-status']['message']) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"signature": {
3+
"token": "fff0ebc59c0516f4ce0823212a2f45e5c67814420b99fe558b",
4+
"timestamp": "1661590666",
5+
"signature": "a0cd251821d8fd56a2130b541becc8e441023574e602fe9829a9ab9fbfdea33f"
6+
},
7+
"event-data": {
8+
"id": "G9Bn5sl1TC6nu79C8C0bwg",
9+
"timestamp": 1521233195.375624,
10+
"log-level": "error",
11+
"event": "failed",
12+
"severity": "permanent",
13+
"reason": "bounce",
14+
"delivery-status": {
15+
"attempt-no": 1,
16+
"message": "No Such User Here",
17+
"code": 550,
18+
"enhanced-code": "",
19+
"session-seconds": 0
20+
},
21+
"flags": {
22+
"is-routed": false,
23+
"is-authenticated": true,
24+
"is-system-test": false,
25+
"is-test-mode": false
26+
},
27+
"envelope": {
28+
"sender": "bob@app.symfony.com",
29+
"transport": "smtp",
30+
"targets": "alice@example.com"
31+
},
32+
"message": {
33+
"headers": {
34+
"to": "Alice <alice@example.com>",
35+
"message-id": "20130503192659.13651.20287@app.symfony.com",
36+
"from": "Bob <bob@app.symfony.com>",
37+
"subject": "Test permanent_fail webhook"
38+
},
39+
"attachments": [],
40+
"size": 111
41+
},
42+
"recipient": "alice@example.com",
43+
"recipient-domain": "example.com",
44+
"storage": {
45+
"url": "https://se.api.mailgun.net/v3/domains/app.symfony.com/messages/message_key",
46+
"key": "message_key"
47+
},
48+
"campaigns": [],
49+
"tags": [
50+
"my_tag_1",
51+
"my_tag_2"
52+
],
53+
"user-variables": {
54+
"my_var_1": "Mailgun Variable #1",
55+
"my-var-2": "awesome"
56+
}
57+
}
58+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
use Symfony\Component\RemoteEvent\Event\Mailer\MailerDeliveryEvent;
4+
5+
$wh = new MailerDeliveryEvent(MailerDeliveryEvent::BOUNCE, 'G9Bn5sl1TC6nu79C8C0bwg', json_decode(file_get_contents(str_replace('.php', '.json', __FILE__)), true, flags: JSON_THROW_ON_ERROR)['event-data']);
6+
$wh->setRecipientEmail('alice@example.com');
7+
$wh->setTags(['my_tag_1', 'my_tag_2']);
8+
$wh->setMetadata(['my_var_1' => 'Mailgun Variable #1', 'my-var-2' => 'awesome']);
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u', '1521233195.375624'));
10+
$wh->setReason('No Such User Here');
11+
12+
return $wh;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy