Module: EffectivePostmarkUser
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_postmark_user.rb
Overview
EffectivePostmarkUsr
Mark your user model with effective_postmark_user
#<Postmark::InactiveRecipientError: You tried to send to recipient(s) that have been marked as inactive. Found inactive addresses: [email protected]. Inactive recipients are ones that have generated a hard bounce, a spam complaint, or a manual suppression.>
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary collapse
-
#postmark_inactive_recipient! ⇒ Object
Triggered by the EffectivePostmarkMailer concern when a Postmark::InactiveRecipientError is raised.
-
#postmark_reactivate! ⇒ Object
Triggered by an admin to reactivate the email address.
Instance Method Details
#postmark_inactive_recipient! ⇒ Object
Triggered by the EffectivePostmarkMailer concern when a Postmark::InactiveRecipientError is raised
35 36 37 38 39 |
# File 'app/models/concerns/effective_postmark_user.rb', line 35 def postmark_inactive_recipient! return if email_delivery_error.present? # If we already marked invalid, don't mark again update_columns(email_delivery_error: 'Inactive Recipient', email_delivery_error_at: Time.zone.now) end |
#postmark_reactivate! ⇒ Object
Triggered by an admin to reactivate the email address
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/concerns/effective_postmark_user.rb', line 42 def postmark_reactivate! # Make an API request to reactivate this user EffectivePostmark.api.reactivate(self) # Send a reactivation email. # This could fail again and call postmark_inactive_recipient! behind the scenes = EffectivePostmark.mailer_class.send(:reactivated, self).deliver_now return false if .kind_of?(Exception) # This worked. We've been reactivated. Clear the error update_columns(email_delivery_error: nil, email_delivery_error_at: nil) end |