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

Instance Method Details

#postmark_inactive_recipient!Object

Triggered by the EffectivePostmarkMailer concern when a Postmark::InactiveRecipientError is raised



34
35
36
37
38
# File 'app/models/concerns/effective_postmark_user.rb', line 34

def postmark_inactive_recipient!
  return unless postmark_valid? # If we already marked invalid, don't mark again

  update_columns(postmark_error: 'Inactive Recipient', postmark_error_at: Time.zone.now)
end

#postmark_invalid?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/models/concerns/effective_postmark_user.rb', line 58

def postmark_invalid?
  postmark_error.present?
end

#postmark_reactivate!Object

Triggered by an admin to reactivate the email address



41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/concerns/effective_postmark_user.rb', line 41

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
  message = EffectivePostmark.mailer_class.send(:reactivated, self).deliver_now
  return false if message.kind_of?(Exception)

  # This worked. We've been reactivated. Clear the error
  update_columns(postmark_error: nil, postmark_error_at: nil)
end

#postmark_valid?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/models/concerns/effective_postmark_user.rb', line 54

def postmark_valid?
  postmark_error.blank?
end