module Sisimai::Reason::UserUnknown

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

This is the error that a local part (Left hand side of @ sign) of a recipient's email address does not exist. In many case, a user has changed internet service provider, or has quit company, or the local part is misspelled. Sisimai will set “userunknown” to the reason of email bounce if the value of Status: field in a bounce email is “5.1.1”, or connection was refused at SMTP RCPT command, or the contents of Diagnostic-Code: field represents that it is unknown user.

<kijitora@example.co.jp>: host mx01.example.co.jp[192.0.2.8] said:
550 5.1.1 Address rejected kijitora@example.co.jp (in reply to
RCPT TO command)

Constants

ModulePath
PreMatches
Regex

Public Class Methods

description() click to toggle source
# File lib/sisimai/reason/userunknown.rb, line 152
def description; return "Email rejected due to a local part of a recipient's email address does not exist"; end
match(argv1) click to toggle source

Try to match that the given text and regular expressions @param [String] argv1 String to be matched with regular expressions @return [True,False] false: Did not match

true: Matched
# File lib/sisimai/reason/userunknown.rb, line 158
def match(argv1)
  return nil unless argv1
  return true if argv1 =~ Regex
  return false
end
text() click to toggle source
# File lib/sisimai/reason/userunknown.rb, line 151
def text; return 'userunknown'; end
true(argvs) click to toggle source

Whether the address is “userunknown” or not @param [Sisimai::Data] argvs Object to be detected the reason @return [True,False] true: is unknown user

false: is not unknown user.

@see www.ietf.org/rfc/rfc2822.txt

# File lib/sisimai/reason/userunknown.rb, line 169
def true(argvs)
  return true if argvs.reason == 'userunknown'

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

  diagnostic = argvs.diagnosticcode.downcase
  if tempreason == 'userunknown'
    # *.1.1 = 'Bad destination mailbox address'
    #   Status: 5.1.1
    #   Diagnostic-Code: SMTP; 550 5.1.1 <***@example.jp>:
    #     Recipient address rejected: User unknown in local recipient table
    matchother = false
    PreMatches.each do |e|
      # Check the value of "Diagnostic-Code" with other error patterns.
      p = 'Sisimai::Reason::' << e
      r = nil
      begin
        require ModulePath[p]
        r = Module.const_get(p)
      rescue
        warn '***warning: Failed to load ' << p
        next
      end

      next unless r.match(diagnostic)
      # Match with reason defined in Sisimai::Reason::* except UserUnknown.
      matchother = true
      break
    end
    return true unless matchother # Did not match with other message patterns

  elsif argvs.smtpcommand == 'RCPT'
    # When the SMTP command is not "RCPT", the session rejected by other
    # reason, maybe.
    return true if match(diagnostic)
  end

  return false
end