Module: Sisimai::Reason::Filtered

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

Overview

Sisimai::Reason::Filtered checks the bounce reason is “filtered” or not. This class is called only Sisimai::Reason class.

This is the error that an email has been rejected by a header content after SMTP DATA command. In Japanese cellular phones, the error will incur that a sender’s email address or a domain is rejected by recipient’s email configuration. Sisimai will set “filtered” to the reason of email bounce if the value of Status: field in a bounce email is “5.2.0” or “5.2.1”.

Constant Summary collapse

Index =
[
  "account is protected by",
  "has restricted sms e-mail", # AT&T
  "is not accepting any mail",
  "message filtered",
  "message rejected due to user rules",
  "not found recipient account",
  "recipient id refuse to receive mail", # Willcom
  "recipient is only accepting mail from specific email addresses", # AOL Phoenix
  "refused due to recipient preferences", # Facebook
  "user refuses to receive this mail",
  "user reject",
  "you have been blocked by the recipient",
].freeze

Class Method Summary collapse

Class Method Details

.descriptionObject



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

def description; return 'Email rejected due to a header content after SMTP DATA command'; 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



33
34
35
36
37
# File 'lib/sisimai/reason/filtered.rb', line 33

def match(argv1)
  return false if argv1.nil? || argv1.empty?
  return true  if Index.any? { |a| argv1.include?(a) }
  return false
end

.textObject



27
# File 'lib/sisimai/reason/filtered.rb', line 27

def text; return 'filtered'; end

.true(argvs) ⇒ Boolean

Rejected by a sender domain or a sender address by a filter ?

Parameters:

Returns:

  • (Boolean)

    true: is filtered false: is not filtered

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sisimai/reason/filtered.rb', line 44

def true(argvs)
  return true if argvs['reason'] == 'filtered'

  tempreason = Sisimai::SMTP::Status.name(argvs['deliverystatus'])
  return false if tempreason == 'suspend'

  issuedcode = argvs['diagnosticcode'].downcase || ''
  thecommand = argvs['command']                 || ''
  if tempreason == 'filtered'
    # Delivery status code points "filtered".
    require 'sisimai/reason/userunknown'
    return true if Sisimai::Reason::UserUnknown.match(issuedcode) || match(issuedcode)
  else
    # The value of "reason" isn't "filtered" when the value of "command" is an SMTP command
    # to be sent before the SMTP DATA command because all the MTAs read the headers and the
    # entire message body after the DATA command.
    return false if Sisimai::SMTP::Command::ExceptDATA.include?(thecommand)
    return true  if match(issuedcode) || Sisimai::Reason::UserUnknown.match(issuedcode)
  end
  return false
end