Exception: Tuktuk::Bounce

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/tuktuk/bounce.rb

Direct Known Subclasses

HardBounce, SoftBounce

Constant Summary collapse

HARD_BOUNCE_CODES =
[
  501, # Bad address syntax (eg. "[email protected]")
  504, # mailbox is disabled
  511, # sorry, no mailbox here by that name (#5.1.1 - chkuser)
  540, # recipient's email account has been suspended.
  550, # Requested action not taken: mailbox unavailable
  552, # Spam Message Rejected -- Requested mail action aborted: exceeded storage allocation
  554, # Recipient address rejected: Policy Rejection- Abuse. Go away -- This user doesn't have a yahoo.com account
  563, # ERR_MSG_REJECT_BLACKLIST, message has blacklisted content and thus I reject it
  571  # Delivery not authorized, message refused
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.type(e) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/tuktuk/bounce.rb', line 17

def self.type(e)
  if e.is_a?(Net::SMTPFatalError) and code = e.to_s[0..2] and HARD_BOUNCE_CODES.include? code.to_i
    HardBounce.new(e)
  else
    SoftBounce.new(e) # either soft mailbox bounce, timeout or server bounce
  end
end

Instance Method Details

#codeObject



25
26
27
28
29
# File 'lib/tuktuk/bounce.rb', line 25

def code
  if str = to_s[0..2] and str.gsub(/[^0-9]/, '') != ''
    str.to_i
  end
end