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



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

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



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

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



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

def text; return 'requireptr'; 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:



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

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