Module: Sisimai::Rhost::GSuite

Defined in:
lib/sisimai/rhost/gsuite.rb

Overview

Sisimai::Rhost detects the bounce reason from the content of Sisimai::Fact object as an argument of find() method when the value of “rhost” of the object is “*.googlemail.com”. This class is called only from Sisimai::Fact class.

Constant Summary collapse

MessagesOf =
{
  "hostunknown"  => [" responded with code NXDOMAIN", "Domain name not found"],
  "networkerror" => [" had no relevant answers.", "responded with code NXDOMAIN", "Domain name not found"],
  "notaccept"    => ["Null MX"],
  "userunknown"  => ["because the address couldn't be found. Check for typos or unnecessary spaces and try again."],
}.freeze

Class Method Summary collapse

Class Method Details

.find(argvs) ⇒ String

Detect bounce reason from Gsuite Mail: www.aol.com

Parameters:

Returns:

  • (String)

    The bounce reason for Gsuite

Since:

  • v5.2.0



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sisimai/rhost/gsuite.rb', line 19

def find(argvs)
  return "" if argvs["diagnosticcode"].empty?
  statuscode = ""; statuscode = argvs["deliverystatus"][0, 1] if argvs["deliverystatus"].empty? == false
  esmtpreply = ""; esmtpreply = argvs["replycode"][0, 1]      if argvs["replycode"].empty?      == false
  reasontext = ""

  MessagesOf.each_key do |e|
    # Try to match the error message with message patterns defined in $MessagesOf
    next if MessagesOf[e].none? { |a| argvs["diagnosticcode"].include?(a) }
    next if e == "networkerror" && (statuscode == "5" || esmtpreply == "5")
    next if e == "hostunknown"  && (statuscode == "4" || statuscode == "")
    next if e == "hostunknown"  && (esmtpreply == "4" || esmtpreply == "")
    reasontext = e
    break
  end

  return reasontext
end