Skip to content

Commit

Permalink
Add check for SES 'invalid domain' transient bounces. Closes #1463.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Aug 20, 2023
1 parent e2f1313 commit 4b05ab1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/bounce/webhooks/ses.go
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 4b05ab1

Please sign in to comment.