Module: Sisimai::Reason::RequirePTR

Defined in:
lib/sisimai/reason/requireptr.rb

Overview

Sisimai::Reason::RequirePTR checks the bounce reason is "RequirePTR" or not. This class is called only from Sisimai::Reason class. This is the error that SMTP connection was rejected due to missing PTR record or having invalid PTR record at the source IP address used for the SMTP connection.

Constant Summary collapse

Index =
[
  "cannot find your hostname",
  "cannot resolve your address.",
  "corresponding forward dns entry does not point to the sending ip", # Google
  "ip name lookup failed",
  "no matches to nameserver query",
  "sender ip reverse lookup rejected",
  "unresolvable relay host name",
].freeze
Pairs =
[
  ["domain "," mismatches client ip"],
  ["domain name verification on your ip address ", "failed"],
  ["dns lookup failure: ", " try again later"],
  ["ptr", "record"],
  ["reverse", " dns"],
  ["server access ", " forbidden by invalid rdns record of your mail server"],
  ["service permits ", " unverifyable sending ips"],
].freeze

Class Method Summary collapse

Class Method Details

.descriptionObject



30
# File 'lib/sisimai/reason/requireptr.rb', line 30

def description; return 'Email rejected due to missing PTR record or having invalid PTR record'; end

.match(argv1) ⇒ Boolean

Try to match that the given text and regular expressions

Parameters:

  • argv1 (String)

    String to be matched with regular expressions

Returns:

  • (Boolean)

    false: Did not match, true: Matched



35
36
37
38
39
40
# File 'lib/sisimai/reason/requireptr.rb', line 35

def match(argv1)
  return false if argv1.nil? || argv1.empty?
  return true  if Index.any? { |a| argv1.include?(a) }
  return true  if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
  return false
end

.textObject



29
# File 'lib/sisimai/reason/requireptr.rb', line 29

def text; return Sisimai::Eb::ReQPTR; end

.true(argvs) ⇒ Boolean

Check the email rejected due to missing PTR record or having invalid PTR record OR not

Parameters:

  • argvs (Hash)

    Hash to be detected the value of reason

Returns:

  • (Boolean)

    true: is missing PTR or invalid PTR false: is not blocked due to missing PTR record

See Also:



47
48
49
50
51
# File 'lib/sisimai/reason/requireptr.rb', line 47

def true(argvs)
  return true if argvs['reason'] == Sisimai::Eb::ReQPTR
  return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']) == Sisimai::Eb::ReQPTR
  return match(argvs['diagnosticcode'].downcase)
end