module Sisimai::Rhost::Cox

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

ErrorCodes

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

MessagesOf

Public Class Methods

get(argvs) click to toggle source

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

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

  if cv = statusmesg.match(/AUP#([0-9A-Z]+)/)
    # Capture the numeric part of the error code
    codenumber = cv[1]
  end
  reasontext = ErrorCodes[codenumber] || ''

  if reasontext.empty?
    # The error code was not found in ErrorCodes
    MessagesOf.each_key do |e|
      # Try to find with each error message defined in MessagesOf
      next unless MessagesOf[e].any? { |a| statusmesg.include?(a) }
      reasontext = e
      break
    end
  end

  return reasontext
end