Skip to content

Instantly share code, notes, and snippets.

@trusche
Last active September 17, 2025 19:27
Show Gist options
  • Select an option

  • Save trusche/8b72db0d89c7f7a990e4a3f85e3e2dc2 to your computer and use it in GitHub Desktop.

Select an option

Save trusche/8b72db0d89c7f7a990e4a3f85e3e2dc2 to your computer and use it in GitHub Desktop.
namespace :postmark do
desc "Sync bounces from postmark to users"
task :sync_bounces => [:environment] do
client = Postmark::ApiClient.new("your api key here")
suppressions = client.dump_suppressions("outbound", type: "bounces")
suppressions.each do |suppression|
if user = User.find_by(email: suppression[:email_address])
user.update(
email_bounced_at: suppression[:created_at],
email_bounce_details: suppression[:suppression_reason]
)
else
# You might as well use the Postmark API to delete
# those dangling supressions here.
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment