Last active
September 17, 2025 19:27
-
-
Save trusche/8b72db0d89c7f7a990e4a3f85e3e2dc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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