module Sisimai::Rhost::Spectrum

Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data object as an argument of get() method when the value of “destination” of the object is “charter.net”. This class is called only Sisimai::Data class.

Constants

CodeRanges
ErrorCodes

Imported from p5-Sisimail/lib/Sisimai/Rhost/Spectrum.pm

Public Class Methods

get(argvs) click to toggle source

Detect bounce reason from www.spectrum.com/ @param [Sisimai::Data] argvs Parsed email object @return [String, Nil] The bounce reason at Spectrum @since v4.25.8

# File lib/sisimai/rhost/spectrum.rb, line 45
def get(argvs)
  statusmesg = argvs.diagnosticcode
  codenumber = 0

  if cv = statusmesg.match(/AUP#[-A-Za-z]*(\d{4})/)
    # Capture the numeric part of the error code
    codenumber = cv[1].to_i
  end
  reasontext = ErrorCodes[codenumber] || ''

  if reasontext.empty?
    # The error code was not found in ErrorCodes
    CodeRanges.each do |e|
      # Check the code range
      next if codenumber < e[0]
      next if codenumber > e[1]
      reasontext = e[2]
      break
    end
  end

  return reasontext
end