module Sisimai

www.ietf.org/rfc/rfc5321.txt

 4.2.1.  Reply Code Severities and Theory
     2yz  Positive Completion reply
     3yz  Positive Intermediate reply
     4yz  Transient Negative Completion reply
     5yz  Permanent Negative Completion reply

     x0z  Syntax: These replies refer to syntax errors, syntactically
          correct commands that do not fit any functional category, and
          unimplemented or superfluous commands.
     x1z  Information: These are replies to requests for information, such
          as status or help.
     x2z  Connections: These are replies referring to the transmission
          channel.
     x3z  Unspecified.
     x4z  Unspecified.
     x5z  Mail system: These replies indicate the status of the receiver
          mail system vis-a-vis the requested transfer or other mail system
          action.

4.2.3.  Reply Codes in Numeric Order
     211  System status, or system help reply
     214  Help message (Information on how to use the receiver or the
          meaning of a particular non-standard command; this reply is useful
          only to the human user)
     220  <domain> Service ready
     221  <domain> Service closing transmission channel
     250  Requested mail action okay, completed
     251  User not local; will forward to <forward-path> (See Section 3.4)
     252  Cannot VRFY user, but will accept message and attempt delivery
          (See Section 3.5.3)
     354  Start mail input; end with <CRLF>.<CRLF>
     421  <domain> Service not available, closing transmission channel
          (This may be a reply to any command if the service knows it must
          shut down)
     450  Requested mail action not taken: mailbox unavailable (e.g.,
          mailbox busy or temporarily blocked for policy reasons)
     451  Requested action aborted: local error in processing
     452  Requested action not taken: insufficient system storage
     455  Server unable to accommodate parameters
     500  Syntax error, command unrecognized (This may include errors such
          as command line too long)
     501  Syntax error in parameters or arguments
     502  Command not implemented (see Section 4.2.4)
     503  Bad sequence of commands
     504  Command parameter not implemented
     550  Requested action not taken: mailbox unavailable (e.g., mailbox
          not found, no access, or command rejected for policy reasons)
     551  User not local; please try <forward-path> (See Section 3.4)
     552  Requested mail action aborted: exceeded storage allocation
     553  Requested action not taken: mailbox name not allowed (e.g.,
          mailbox syntax incorrect)
     554  Transaction failed (Or, in the case of a connection-opening
          response, "No SMTP service here")
     555  MAIL FROM/RCPT TO parameters not recognized or not implemented

X.7.7 — Message integrity failure:(RFC 3463)

A transport system otherwise authorized to validate a message
was unable to do so because the message was corrupted or altered.
This may be useful as a permanent, transient persistent, or
successful delivery code.

X.7.8 535 Trust relationship required:(RFC 4954)

554      This response to the AUTH command indicates that the authentication
         failed due to invalid or insufficient authentication credentials.
         In this case, the client SHOULD ask the user to supply new credentials
         (such as by presenting a password dialog box).

X.7.9 534 Authentication mechanism is too weak:(RFC 4954)

This response to the AUTH command indicates that the selected
authentication mechanism is weaker than server policy permits
for that user. The client SHOULD retry with a new authentication
mechanism.

X.7.10 523 Encryption Needed:(RFC 5248)

This indicates that external strong privacy layer is needed in
order to use the requested authentication mechanism. This is
primarily intended for use with clear text authentication mechanisms.
A client which receives this may activate a security layer such
as TLS prior to authenticating, or attempt to use a stronger
mechanism.

X.7.11 524 Encryption required for requested authentication mechanism:(RFC 4954)

538      This response to the AUTH command indicates that the selected
         authentication mechanism may only be used when the underlying
         SMTP connection is encrypted. Note that this response code is
         documented here for historical purposes only. Modern implementations
         SHOULD NOT advertise mechanisms that are not permitted due to
         lack of encryption, unless an encryption layer of sufficient
         strength is currently being employed.

X.7.12 422 A password transition is needed:(RFC 4954)

432      This response to the AUTH command indicates that the user needs
         to transition to the selected authentication mechanism. This
         is typically done by authenticating once using the [PLAIN]
         authentication mechanism. The selected mechanism SHOULD then
         work for authentications in subsequent sessions.

X.7.13 525 User Account Disabled:(RFC 5248)

Sometimes a system administrator will have to disable a user's
account (e.g., due to lack of payment, abuse, evidence of a
break-in attempt, etc).
This error code occurs after a successful authentication to a
disabled account. This informs the client that the failure is
permanent until the user contacts their system administrator
to get the account re-enabled.
It differs from a generic authentication failure where the
client's best option is to present the passphrase entry dialog
in case the user simply mistyped their passphrase.

X.7.14 535 Trust relationship required:(RFC 5248)

554      The submission server requires a configured trust relationship
         with a third-party server in order to access the message content.
         This value replaces the prior use of X.7.8 for this error condition.
         thereby updating [RFC4468].

X.7.15 450 Priority Level is too low:(RFC6710)

550      The specified priority level is below the lowest priority acceptable
4xx      for the receiving SMTP server. This condition might be temporary,
5xx      for example the server is operating in a mode where only higher
         priority messages are accepted for transfer and delivery, while
         lower priority messages are rejected.

X.7.16 552 Message is too big for the specified priority:(RFC 6710)

4xx      The message is too big for the specified priority.
5xx      This condition might be temporary, for example the server is
         operating in a mode where only higher priority messages below
         certain size are accepted for transfer and delivery.

X.7.17 5xx Mailbox owner has changed:(RFC 6710)

This status code is returned when a message is received with
a Require-Recipient-Valid-Since field or RRVS extension and
the receiving system is able to determine that the intended
recipient mailbox has not been under continuous ownership since
the specified date-time.

X.7.18 5xx Domain owner has changed:(RFC 7293)

This status code is returned when a message is received with
a Require-Recipient-Valid-Since field or RRVS extension and
the receiving system wishes to disclose that the owner of the
domain name of the recipient has changed since the specified
date-time.

X.7.19 5xx RRVS test cannot be completed:(RFC 7293)

This status code is returned when a message is received with
a Require-Recipient-Valid-Since field or RRVS extension and
the receiving system cannot complete the requested evaluation
because the required timestamp was not recorded.
The message originator needs to decide whether to reissue the
message without RRVS protection.

X.7.20 550 No passing DKIM signature found:(RFC 7372)

This status code is returned when a message did not contain
any passing DKIM signatures. (This violates the advice of
Section 6.1 of [RFC6376].)

X.7.21 550 No acceptable DKIM signature found:(RFC 7372, 6476)

This status code is returned when a message contains one or
more passing DKIM signatures, but none are acceptable.
(This violates the advice of Section 6.1 of [RFC6376].)

X.7.22 550 No valid author-matched DKIM signature found:(RFC 7372)

This status code is returned when a message contains one or
more passing DKIM signatures, but none are acceptable because
none have an identifier(s) that matches the author address(es)
found in the From header field.
This is a special case of X.7.21. (This violates the advice of
Section 6.1 of [RFC6376].)

X.7.23 550 SPF validation failed:(RFC 7273, 7208)

This status code is returned when a message completed an SPF
check that produced a "fail" result, contrary to local policy
requirements. Used in place of 5.7.1 as described in Section
8.4 of [RFC7208].

X.7.24 451 SPF validation error:(RFC 7372, 7208)

550      This status code is returned when evaluation of SPF relative
         to an arriving message resulted in an error. Used in place of
         4.4.3 or 5.5.2 as described in Sections 8.6 and 8.7 of [RFC7208].

X.7.25 550 Reverse DNS validation failed:(RFC 7372, 7601)

This status code is returned when an SMTP client's IP address
failed a reverse DNS validation check, contrary to local policy
requirements.

X.7.26 550 Multiple authentication checks failed:(RFC 7372)

This status code is returned when a message failed more than
one message authentication check, contrary to local policy
requirements. The particular mechanisms that failed are not
specified.

X.7.27 550 Sender address has null MX:(RFC 7505)

This status code is returned when the associated sender address
has a null MX, and the SMTP receiver is configured to reject
mail from such sender (e.g., because it could not return a DSN).

SAMPLES

554 5.5.0   No recipients have been specified
503 5.5.0   Valid RCPT TO required before BURL
554 5.6.3   Conversion required but not supported
554 5.3.4   Message too big for system
554 5.7.8   URL resolution requires trust relationship
552 5.2.2   Mailbox full
554 5.6.6   IMAP URL resolution failed
250 2.5.0   Waiting for additional BURL or BDAT commands
451 4.4.1   IMAP server unavailable
250 2.5.0   Ok.
250 2.6.4   MIME header conversion with loss performed
235 2.7.0   Authentication Succeeded
432 4.7.12  A password transition is needed
454 4.7.0   Temporary authentication failure
534 5.7.9   Authentication mechanism is too weak
535 5.7.8   Authentication credentials invalid
500 5.5.6   Authentication Exchange line is too long
530 5.7.0   Authentication required
538 5.7.11  Encryption required for requested authentication
    5.7.8   Authentication credentials invalid
    5.7.9   Authentication mechanism is too weak
    5.7.11  Encryption required for requested authentication mechanism

Define the version number of Sisimai

Constants

VERSION

Public Class Methods

dump(argv0, **argv1) click to toggle source

Wrapper method to parse mailbox/Maildir and dump as JSON @param [String] argv0 Path to mbox or Maildir/ @param [Hash] argv0 or Hash (decoded JSON) @param [IO] argv0 or STDIN object @param [Hash] argv1 Parser options @options argv1 [Integer] delivered true: Include “delivered” reason @options argv1 [Lambda] hook Lambda object to be called back @return [String] Parsed data as JSON text

# File lib/sisimai.rb, line 54
def dump(argv0, **argv1)
  return nil unless argv0

  nyaan = Sisimai.make(argv0, **argv1) || []
  if RUBY_PLATFORM.start_with?('java')
    # java-based ruby environment like JRuby.
    require 'jrjackson'
    jsonstring = JrJackson::Json.dump(nyaan)
  else
    require 'oj'
    jsonstring = Oj.dump(nyaan, :mode => :compat)
  end
  return jsonstring
end
engine() click to toggle source

Parser engine list (MTA modules) @return [Hash] Parser engine table

# File lib/sisimai.rb, line 71
def engine
  table = {}

  %w[Lhost ARF RFC3464 RFC3834].each do |e|
    r = 'Sisimai::' << e
    require r.gsub('::', '/').downcase

    if e == 'Lhost'
      # Sisimai::Lhost::*
      Module.const_get(r).send(:index).each do |ee|
        # Load and get the value of "description" from each module
        rr = 'Sisimai::' << e + '::' << ee
        require rr.gsub('::', '/').downcase
        table[rr.to_sym] = Module.const_get(rr).send(:description)
      end
    else
      # Sisimai::ARF, Sisimai::RFC3464, and Sisimai::RFC3834
      table[r.to_sym] = Module.const_get(r).send(:description)
    end
  end

  return table
end
libname() click to toggle source
# File lib/sisimai.rb, line 12
def libname(); return 'Sisimai';        end
make(argv0, **argv1) click to toggle source

Wrapper method for parsing mailbox/maidir @param [String] argv0 Path to mbox or Maildir/ @param [Hash] argv0 or Hash (decoded JSON) @param [IO] argv0 or STDIN object @param [Hash] argv1 Parser options(delivered=false) @options argv1 [Boolean] delivered true: Include “delivered” reason @options argv1 [Lambda] hook Lambda object to be called back @return [Array] Parsed objects @return [nil] nil if the argument was wrong or an empty array

# File lib/sisimai.rb, line 23
def make(argv0, **argv1)
  return nil unless argv0
  require 'sisimai/data'
  require 'sisimai/message'
  require 'sisimai/mail'

  list = []
  return nil unless mail = Sisimai::Mail.new(argv0)
  while r = mail.data.read do
    # Read and parse each email file
    methodargv = { data: r, hook: argv1[:hook] }
    mesg = Sisimai::Message.new(**methodargv)
    next if mesg.void

    methodargv = { data: mesg, delivered: argv1[:delivered], origin: mail.data.path }
    next unless data = Sisimai::Data.make(**methodargv)
    list += data unless data.empty?
  end

  return nil if list.empty?
  return list 
end
match(argvs = '') click to toggle source

Try to match with message patterns @param [String] Error message text @return [String] Reason text

# File lib/sisimai.rb, line 117
def match(argvs = '')
  return nil if argvs.empty?
  require 'sisimai/reason'
  return Sisimai::Reason.match(argvs.downcase)
end
reason() click to toggle source

Reason list Sisimai can detect @return [Hash] Reason list table

# File lib/sisimai.rb, line 97
def reason
  require 'sisimai/reason'
  table = {}
  names = Sisimai::Reason.index

  # These reasons are not included in the results of Sisimai::Reason.index
  names += %w[Delivered Feedback Undefined Vacation]
  while e = names.shift do
    # Call .description() method of Sisimai::Reason::*
    r = 'Sisimai::Reason::' << e
    require r.gsub('::', '/').downcase
    table[e.to_sym] = Module.const_get(r).send(:description)
  end

  return table
end
sysname() click to toggle source
# File lib/sisimai.rb, line 11
def sysname(); return 'bouncehammer';   end
version() click to toggle source
# File lib/sisimai.rb, line 10
def version(); return Sisimai::VERSION; end