AWS - Cleaning the suppression list on SES

AWS
SES
Email

AWS' Simple Email Service (SES) provides a mechanism to prevent sending emails to addresses that marked the email as spam or bounced. If an email is added to the suppression list, the address won't ever receive an email from your AWS account again. These bounces are not always non-existent email addresses. Oftentimes they bounce due to short time server failures.

AWS has a CLI command to manipulate the suppression list. But it's designed to remove the items one by one which can be daunting.

Here are some scripts to save the suppression list locally or to purge it directly from the suppression list. I suggest only purging bounced emails:

# If you have more than 1000 emails, use --next-token with the token to get the next 1000

# Save a list with all the details to a file
aws sesv2 list-suppressed-destinations --no-paginate --reasons BOUNCE > suppression-list.txt

# Save a list of email addresses only to file
aws sesv2 list-suppressed-destinations --no-paginate --reasons BOUNCE | grep -o '"EmailAddress": "[^"]*' | grep -o '[^"]*$' > suppression-list-emails-only.txt

# Purge the bounced suppression list
for email in $(aws sesv2 list-suppressed-destinations --no-paginate --reasons BOUNCE | grep -o '"EmailAddress": "[^"]*' | grep -o '[^"]*$'); do aws sesv2 delete-suppressed-destination --email-address ${email}; echo ${email}; done

Author photo
Cornel Rautenbach
January 20th, 2022