From 4b05ab1920c3338c94b7e790e5c6a94c0faf9686 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 20 Aug 2023 09:47:59 +0530 Subject: [PATCH] Add check for SES 'invalid domain' transient bounces. Closes #1463. --- internal/bounce/webhooks/ses.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/bounce/webhooks/ses.go b/internal/bounce/webhooks/ses.go index 1a9361b..536ae67 100644 --- a/internal/bounce/webhooks/ses.go +++ b/internal/bounce/webhooks/ses.go @@ -49,7 +49,10 @@ type sesMail struct { EventType string `json:"eventType"` NotifType string `json:"notificationType"` Bounce struct { - BounceType string `json:"bounceType"` + BounceType string `json:"bounceType"` + BouncedRecipients []struct { + Status string `json:"status"` + } `json:"bouncedRecipients"` } `json:"bounce"` Mail struct { Timestamp sesTimestamp `json:"timestamp"` @@ -132,6 +135,12 @@ func (s *SES) ProcessBounce(b []byte) (models.Bounce, error) { if m.Bounce.BounceType == "Permanent" { typ = models.BounceTypeHard } + if m.Bounce.BounceType == "Transient" && len(m.Bounce.BouncedRecipients) > 0 { + // "Invalid domain" bounce. + if m.Bounce.BouncedRecipients[0].Status == "5.4.4" { + typ = models.BounceTypeHard + } + } if m.NotifType == "Complaint" { typ = models.BounceTypeComplaint }