diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/RemoteEvent/MailgunPayloadConverter.php b/src/Symfony/Component/Mailer/Bridge/Mailgun/RemoteEvent/MailgunPayloadConverter.php index cb3f323861030..02e04104ac6b9 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/RemoteEvent/MailgunPayloadConverter.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/RemoteEvent/MailgunPayloadConverter.php @@ -75,7 +75,7 @@ private function matchFailedEvent(array $payload): string private function getReason(array $payload): string { - if ('' !== $payload['delivery-status']['description']) { + if ('' !== ($payload['delivery-status']['description'] ?? '')) { return $payload['delivery-status']['description']; } if ('' !== $payload['delivery-status']['message']) { diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/permanent_failure_no_description.json b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/permanent_failure_no_description.json new file mode 100644 index 0000000000000..6f613a0efa3d3 --- /dev/null +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/permanent_failure_no_description.json @@ -0,0 +1,58 @@ +{ + "signature": { + "token": "fff0ebc59c0516f4ce0823212a2f45e5c67814420b99fe558b", + "timestamp": "1661590666", + "signature": "a0cd251821d8fd56a2130b541becc8e441023574e602fe9829a9ab9fbfdea33f" + }, + "event-data": { + "id": "G9Bn5sl1TC6nu79C8C0bwg", + "timestamp": 1521233195.375624, + "log-level": "error", + "event": "failed", + "severity": "permanent", + "reason": "bounce", + "delivery-status": { + "attempt-no": 1, + "message": "No Such User Here", + "code": 550, + "enhanced-code": "", + "session-seconds": 0 + }, + "flags": { + "is-routed": false, + "is-authenticated": true, + "is-system-test": false, + "is-test-mode": false + }, + "envelope": { + "sender": "bob@app.symfony.com", + "transport": "smtp", + "targets": "alice@example.com" + }, + "message": { + "headers": { + "to": "Alice ", + "message-id": "20130503192659.13651.20287@app.symfony.com", + "from": "Bob ", + "subject": "Test permanent_fail webhook" + }, + "attachments": [], + "size": 111 + }, + "recipient": "alice@example.com", + "recipient-domain": "example.com", + "storage": { + "url": "https://se.api.mailgun.net/v3/domains/app.symfony.com/messages/message_key", + "key": "message_key" + }, + "campaigns": [], + "tags": [ + "my_tag_1", + "my_tag_2" + ], + "user-variables": { + "my_var_1": "Mailgun Variable #1", + "my-var-2": "awesome" + } + } +} diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/permanent_failure_no_description.php b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/permanent_failure_no_description.php new file mode 100644 index 0000000000000..8dfffd0362e85 --- /dev/null +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/permanent_failure_no_description.php @@ -0,0 +1,12 @@ +setRecipientEmail('alice@example.com'); +$wh->setTags(['my_tag_1', 'my_tag_2']); +$wh->setMetadata(['my_var_1' => 'Mailgun Variable #1', 'my-var-2' => 'awesome']); +$wh->setDate(\DateTimeImmutable::createFromFormat('U.u', '1521233195.375624')); +$wh->setReason('No Such User Here'); + +return $wh;