module Sisimai::Rhost::GoogleApps

Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data object as an argument of get() method when the value of “rhost” of the object is “aspmx.l.google.com”. This class is called only Sisimai::Data class.

Constants

StatusList

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

Public Class Methods

get(argvs) click to toggle source

Detect bounce reason from Google Apps @param [Sisimai::Data] argvs Parsed email object @return [String] The bounce reason for Google Apps @see support.google.com/a/answer/3726730?hl=en

# File lib/sisimai/rhost/googleapps.rb, line 107
def get(argvs)
  return argvs.reason unless argvs.reason.empty?

  (statuscode = argvs.deliverystatus.clone)[0] = 'X'
  return '' unless StatusList[statuscode]

  reasontext = ''
  StatusList[statuscode].each do |e|
    # Try to match
    next unless e[:string].any? { |a| argvs.diagnosticcode.include?(a) }
    reasontext = e[:reason]
    break
  end
  return reasontext
end