sisimai 4.16.0-java → 4.17.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/ANALYTICAL-PRECISION +7 -7
  4. data/Changes +15 -0
  5. data/Makefile +1 -1
  6. data/README.md +30 -28
  7. data/lib/sisimai.rb +20 -1
  8. data/lib/sisimai/address.rb +28 -9
  9. data/lib/sisimai/arf.rb +37 -46
  10. data/lib/sisimai/data.rb +67 -43
  11. data/lib/sisimai/datetime.rb +210 -210
  12. data/lib/sisimai/mda.rb +30 -30
  13. data/lib/sisimai/message.rb +3 -5
  14. data/lib/sisimai/msp/de/einsundeins.rb +14 -42
  15. data/lib/sisimai/msp/de/gmx.rb +17 -44
  16. data/lib/sisimai/msp/jp/biglobe.rb +15 -44
  17. data/lib/sisimai/msp/jp/ezweb.rb +20 -50
  18. data/lib/sisimai/msp/jp/kddi.rb +16 -43
  19. data/lib/sisimai/msp/ru/mailru.rb +20 -48
  20. data/lib/sisimai/msp/ru/yandex.rb +16 -50
  21. data/lib/sisimai/msp/uk/messagelabs.rb +17 -51
  22. data/lib/sisimai/msp/us/amazonses.rb +18 -40
  23. data/lib/sisimai/msp/us/amazonworkmail.rb +17 -35
  24. data/lib/sisimai/msp/us/aol.rb +17 -41
  25. data/lib/sisimai/msp/us/bigfoot.rb +15 -48
  26. data/lib/sisimai/msp/us/facebook.rb +63 -90
  27. data/lib/sisimai/msp/us/google.rb +15 -44
  28. data/lib/sisimai/msp/us/office365.rb +21 -46
  29. data/lib/sisimai/msp/us/outlook.rb +17 -50
  30. data/lib/sisimai/msp/us/receivingses.rb +20 -43
  31. data/lib/sisimai/msp/us/sendgrid.rb +13 -37
  32. data/lib/sisimai/msp/us/verizon.rb +30 -74
  33. data/lib/sisimai/msp/us/yahoo.rb +12 -40
  34. data/lib/sisimai/msp/us/zoho.rb +14 -42
  35. data/lib/sisimai/mta/activehunter.rb +11 -40
  36. data/lib/sisimai/mta/apachejames.rb +18 -40
  37. data/lib/sisimai/mta/courier.rb +20 -57
  38. data/lib/sisimai/mta/domino.rb +24 -56
  39. data/lib/sisimai/mta/exchange.rb +26 -54
  40. data/lib/sisimai/mta/exim.rb +20 -39
  41. data/lib/sisimai/mta/imailserver.rb +26 -71
  42. data/lib/sisimai/mta/interscanmss.rb +26 -44
  43. data/lib/sisimai/mta/mailfoundry.rb +12 -42
  44. data/lib/sisimai/mta/mailmarshalsmtp.rb +13 -43
  45. data/lib/sisimai/mta/mcafee.rb +17 -46
  46. data/lib/sisimai/mta/messagingserver.rb +14 -47
  47. data/lib/sisimai/mta/mfilter.rb +12 -35
  48. data/lib/sisimai/mta/mxlogic.rb +18 -42
  49. data/lib/sisimai/mta/notes.rb +22 -45
  50. data/lib/sisimai/mta/opensmtpd.rb +18 -48
  51. data/lib/sisimai/mta/postfix.rb +15 -45
  52. data/lib/sisimai/mta/qmail.rb +32 -60
  53. data/lib/sisimai/mta/sendmail.rb +13 -38
  54. data/lib/sisimai/mta/surfcontrol.rb +15 -44
  55. data/lib/sisimai/mta/userdefined.rb +14 -30
  56. data/lib/sisimai/mta/v5sendmail.rb +18 -40
  57. data/lib/sisimai/mta/x1.rb +12 -41
  58. data/lib/sisimai/mta/x2.rb +12 -41
  59. data/lib/sisimai/mta/x3.rb +12 -39
  60. data/lib/sisimai/mta/x4.rb +33 -66
  61. data/lib/sisimai/mta/x5.rb +15 -42
  62. data/lib/sisimai/reason.rb +8 -71
  63. data/lib/sisimai/reason/blocked.rb +3 -0
  64. data/lib/sisimai/reason/contenterror.rb +3 -0
  65. data/lib/sisimai/reason/delivered.rb +27 -0
  66. data/lib/sisimai/reason/exceedlimit.rb +3 -0
  67. data/lib/sisimai/reason/expired.rb +3 -0
  68. data/lib/sisimai/reason/feedback.rb +18 -0
  69. data/lib/sisimai/reason/filtered.rb +4 -0
  70. data/lib/sisimai/reason/hasmoved.rb +3 -0
  71. data/lib/sisimai/reason/hostunknown.rb +3 -0
  72. data/lib/sisimai/reason/mailboxfull.rb +3 -0
  73. data/lib/sisimai/reason/mailererror.rb +3 -0
  74. data/lib/sisimai/reason/mesgtoobig.rb +3 -0
  75. data/lib/sisimai/reason/networkerror.rb +3 -0
  76. data/lib/sisimai/reason/norelaying.rb +3 -0
  77. data/lib/sisimai/reason/notaccept.rb +3 -0
  78. data/lib/sisimai/reason/onhold.rb +3 -0
  79. data/lib/sisimai/reason/rejected.rb +3 -0
  80. data/lib/sisimai/reason/securityerror.rb +3 -0
  81. data/lib/sisimai/reason/spamdetected.rb +3 -0
  82. data/lib/sisimai/reason/suspend.rb +3 -0
  83. data/lib/sisimai/reason/syntaxerror.rb +41 -0
  84. data/lib/sisimai/reason/systemerror.rb +3 -0
  85. data/lib/sisimai/reason/systemfull.rb +3 -0
  86. data/lib/sisimai/reason/toomanyconn.rb +3 -0
  87. data/lib/sisimai/reason/undefined.rb +18 -0
  88. data/lib/sisimai/reason/userunknown.rb +3 -0
  89. data/lib/sisimai/reason/vacation.rb +18 -0
  90. data/lib/sisimai/rfc3464.rb +15 -40
  91. data/lib/sisimai/rfc3834.rb +1 -10
  92. data/lib/sisimai/rfc5322.rb +57 -19
  93. data/lib/sisimai/rhost/googleapps.rb +82 -82
  94. data/lib/sisimai/smtp/reply.rb +2 -1
  95. data/lib/sisimai/smtp/status.rb +154 -152
  96. data/lib/sisimai/string.rb +2 -3
  97. data/lib/sisimai/version.rb +1 -1
  98. data/set-of-emails/maildir/bsd/rfc3464-29.eml +60 -0
  99. data/set-of-emails/maildir/bsd/us-amazonworkmail-06.eml +156 -0
  100. data/set-of-emails/maildir/bsd/us-amazonworkmail-07.eml +158 -0
  101. data/set-of-emails/maildir/bsd/us-google-15.eml +97 -0
  102. data/set-of-emails/maildir/bsd/us-google-16.eml +99 -0
  103. data/set-of-emails/maildir/bsd/us-google-17.eml +104 -0
  104. data/set-of-emails/maildir/dos/apachejames-01.eml +4 -4
  105. data/set-of-emails/maildir/dos/us-amazonworkmail-01.eml +156 -0
  106. data/set-of-emails/maildir/dos/us-office365-01.eml +102 -0
  107. data/set-of-emails/maildir/mac/apachejames-01.eml +1 -9
  108. data/set-of-emails/maildir/mac/us-amazonworkmail-01.eml +1 -7
  109. data/set-of-emails/maildir/mac/us-office365-01.eml +1 -4
  110. metadata +17 -2
@@ -0,0 +1,27 @@
1
+ module Sisimai
2
+ module Reason
3
+ # Sisimai::Reason::Delivered checks the email you sent is delivered successfully
4
+ # or not by matching diagnostic messages with message patterns. Sisimai will
5
+ # set "delivered" to the value of "reason" when Status: field in the bounce
6
+ # message begins with "2" like following:
7
+ #
8
+ # Final-Recipient: rfc822; kijitora@neko.nyaan.jp
9
+ # Action: deliverable
10
+ # Status: 2.1.5
11
+ # Diagnostic-Code: SMTP; 250 2.1.5 OK
12
+ #
13
+ # This class is called only Sisimai.reason method. This is NOT AN ERROR reason.
14
+ module Delivered
15
+ # Imported from p5-Sisimail/lib/Sisimai/Reason/Delivered.pm
16
+ class << self
17
+ def text; return 'delivered'; end
18
+ def description
19
+ return 'Email delivered successfully'
20
+ end
21
+ def match; return nil; end
22
+ def true(*); return nil; end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
@@ -10,6 +10,9 @@ module Sisimai
10
10
  # Imported from p5-Sisimail/lib/Sisimai/Reason/ExceedLimit.pm
11
11
  class << self
12
12
  def text; return 'exceedlimit'; end
13
+ def description
14
+ return 'Email rejected due to an email exceeded the limit'
15
+ end
13
16
 
14
17
  # Try to match that the given text and regular expressions
15
18
  # @param [String] argv1 String to be matched with regular expressions
@@ -10,6 +10,9 @@ module Sisimai
10
10
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Expired.pm
11
11
  class << self
12
12
  def text; return 'expired'; end
13
+ def description
14
+ return 'Delivery time has expired due to a connection failure'
15
+ end
13
16
 
14
17
  # Try to match that the given text and regular expressions
15
18
  # @param [String] argv1 String to be matched with regular expressions
@@ -0,0 +1,18 @@
1
+ module Sisimai
2
+ module Reason
3
+ # Sisimai::Reason::Feedback is for only returning text and description.
4
+ # This class is called only from Sisimai.reason method and Sisimai::ARF class.
5
+ module Feedback
6
+ # Imported from p5-Sisimail/lib/Sisimai/Reason/Feedback.pm
7
+ class << self
8
+ def text; return 'feedback'; end
9
+ def description
10
+ return 'Email forwarded to the sender as a complaint message from your mailbox provider'
11
+ end
12
+ def match; return nil; end
13
+ def true(*); return nil; end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -13,6 +13,9 @@ module Sisimai
13
13
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Filtered.pm
14
14
  class << self
15
15
  def text; return 'filtered'; end
16
+ def description
17
+ return 'Email rejected due to a header content after SMTP DATA command'
18
+ end
16
19
 
17
20
  # Try to match that the given text and regular expressions
18
21
  # @param [String] argv1 String to be matched with regular expressions
@@ -28,6 +31,7 @@ module Sisimai
28
31
  being[ ]accepted[ ]for[ ]this[ ]mailbox
29
32
  |has[ ]restricted[ ]SMS[ ]e-mail # AT&T
30
33
  |http://postmaster[.]facebook[.]com/.+refused[ ]due[ ]to[ ]recipient[ ]preferences # Facebook
34
+ |IS[ ]NOT[ ]ACCEPTING[ ]ANY[ ]MAIL
31
35
  |permanent[ ]failure[ ]for[ ]one[ ]or[ ]more[ ]recipients[ ][(].+:blocked[)]
32
36
  |RESOLVER[.]RST[.]NotAuthorized # Microsoft Exchange
33
37
  |This[ ]account[ ]is[ ]protected[ ]by
@@ -10,6 +10,9 @@ module Sisimai
10
10
  # Imported from p5-Sisimail/lib/Sisimai/Reason/HasMoved.pm
11
11
  class << self
12
12
  def text; return 'hasmoved'; end
13
+ def description
14
+ return "Email rejected due to user's mailbox has moved and is not forwarded automatically"
15
+ end
13
16
 
14
17
  # Try to match that the given text and regular expressions
15
18
  # @param [String] argv1 String to be matched with regular expressions
@@ -9,6 +9,9 @@ module Sisimai
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Reason/HostUnknown.pm
10
10
  class << self
11
11
  def text; return 'hostunknown'; end
12
+ def description
13
+ return "Delivery failed due to a domain part of a recipient's email address does not exist"
14
+ end
12
15
 
13
16
  # Try to match that the given text and regular expressions
14
17
  # @param [String] argv1 String to be matched with regular expressions
@@ -10,6 +10,9 @@ module Sisimai
10
10
  # Imported from p5-Sisimail/lib/Sisimai/Reason/MailboxFull.pm
11
11
  class << self
12
12
  def text; return 'mailboxfull'; end
13
+ def description
14
+ return "Email rejected due to a recipient's mailbox is full"
15
+ end
13
16
 
14
17
  # Try to match that the given text and regular expressions
15
18
  # @param [String] argv1 String to be matched with regular expressions
@@ -12,6 +12,9 @@ module Sisimai
12
12
  # Imported from p5-Sisimail/lib/Sisimai/Reason/MailerError.pm
13
13
  class << self
14
14
  def text; return 'mailererror'; end
15
+ def description
16
+ return 'Email returned due to a mailer program has not exited successfully'
17
+ end
15
18
 
16
19
  # Try to match that the given text and regular expressions
17
20
  # @param [String] argv1 String to be matched with regular expressions
@@ -9,6 +9,9 @@ module Sisimai
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Reason/MesgTooBig.pm
10
10
  class << self
11
11
  def text; return 'mesgtoobig'; end
12
+ def description
13
+ return 'Email rejected due to a email size is too big for a destination mail server'
14
+ end
12
15
 
13
16
  # Try to match that the given text and regular expressions
14
17
  # @param [String] argv1 String to be matched with regular expressions
@@ -14,6 +14,9 @@ module Sisimai
14
14
  # Imported from p5-Sisimail/lib/Sisimai/Reason/NetworkError.pm
15
15
  class << self
16
16
  def text; return 'networkerror'; end
17
+ def description
18
+ return 'SMTP connection failed due to DNS look up failure or other network problems'
19
+ end
17
20
 
18
21
  # Try to match that the given text and regular expressions
19
22
  # @param [String] argv1 String to be matched with regular expressions
@@ -14,6 +14,9 @@ module Sisimai
14
14
  # Imported from p5-Sisimail/lib/Sisimai/Reason/NoRelaying.pm
15
15
  class << self
16
16
  def text; return 'norelaying'; end
17
+ def description
18
+ return 'Email rejected with error message "Relaying Denied"'
19
+ end
17
20
 
18
21
  # Try to match that the given text and regular expressions
19
22
  # @param [String] argv1 String to be matched with regular expressions
@@ -12,6 +12,9 @@ module Sisimai
12
12
  # Imported from p5-Sisimail/lib/Sisimai/Reason/NotAccept.pm
13
13
  class << self
14
14
  def text; return 'notaccept'; end
15
+ def description
16
+ return 'Delivery failed due to a destination mail server does not accept any email'
17
+ end
15
18
 
16
19
  # Try to match that the given text and regular expressions
17
20
  # @param [String] argv1 String to be matched with regular expressions
@@ -9,6 +9,9 @@ module Sisimai
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Reason/OnHold.pm
10
10
  class << self
11
11
  def text; return 'onhold'; end
12
+ def description
13
+ return 'Sisimai could not decided the reason due to there is no (or less) detailed information for judging the reason'
14
+ end
12
15
 
13
16
  # Try to match that the given text and regular expressions
14
17
  # @param [String] argv1 String to be matched with regular expressions
@@ -16,6 +16,9 @@ module Sisimai
16
16
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Rejected.pm
17
17
  class << self
18
18
  def text; return 'rejected'; end
19
+ def description
20
+ return "Email rejected due to a sender's email address (envelope from)"
21
+ end
19
22
 
20
23
  # Try to match that the given text and regular expressions
21
24
  # @param [String] argv1 String to be matched with regular expressions
@@ -16,6 +16,9 @@ module Sisimai
16
16
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SecurityError.pm
17
17
  class << self
18
18
  def text; return 'securityerror'; end
19
+ def description
20
+ return 'Email rejected due to security violation was detected on a destination host'
21
+ end
19
22
 
20
23
  # Try to match that the given text and regular expressions
21
24
  # @param [String] argv1 String to be matched with regular expressions
@@ -17,6 +17,9 @@ module Sisimai
17
17
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SpamDetected.pm
18
18
  class << self
19
19
  def text; return 'spamdetected'; end
20
+ def description
21
+ return 'Email rejected by spam filter running on the remote host'
22
+ end
20
23
 
21
24
  # Try to match that the given text and regular expressions
22
25
  # @param [String] argv1 String to be matched with regular expressions
@@ -9,6 +9,9 @@ module Sisimai
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Suspend.pm
10
10
  class << self
11
11
  def text; return 'suspend'; end
12
+ def description
13
+ return 'Email rejected due to a recipient account is being suspended'
14
+ end
12
15
 
13
16
  # Try to match that the given text and regular expressions
14
17
  # @param [String] argv1 String to be matched with regular expressions
@@ -0,0 +1,41 @@
1
+ module Sisimai
2
+ module Reason
3
+ # Sisimai::Reason::SyntaxError checks the bounce reason is "syntaxerror" or
4
+ # not. This class is called only Sisimai::Reason class.
5
+ #
6
+ # This is the error that a destination mail server could not recognize SMTP
7
+ # command which is sent from a sender's MTA. Sisimai will set "syntaxerror"
8
+ # to the reason if the value of "replycode" begins with "50" such as 502,
9
+ # or 503.
10
+ # Action: failed
11
+ # Status: 5.5.0
12
+ # Diagnostic-Code: SMTP; 503 Improper sequence of commands
13
+ #
14
+ module SyntaxError
15
+ # Imported from p5-Sisimail/lib/Sisimai/Reason/SyntaxError.pm
16
+ class << self
17
+ def text; return 'syntaxerror'; end
18
+ def description
19
+ return 'Email rejected due to syntax error at sent commands in SMTP session'
20
+ end
21
+ def match(*); return nil; end
22
+
23
+ # Connection rejected due to syntax error or not
24
+ # @param [Sisimai::Data] argvs Object to be detected the reason
25
+ # @return [True,False] true: Connection rejected due to
26
+ # syntax error
27
+ # false: is not syntax error
28
+ # @see http://www.ietf.org/rfc/rfc2822.txt
29
+ def true(argvs)
30
+ return nil unless argvs
31
+ return nil unless argvs.is_a? Sisimai::Data
32
+ return true if argvs.reason == Sisimai::Reason::SyntaxError.text
33
+ return true if argvs.replycode =~ /\A[45]0[0-7]\z/
34
+ return false
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
41
+
@@ -13,6 +13,9 @@ module Sisimai
13
13
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SystemError.pm
14
14
  class << self
15
15
  def text; return 'systemerror'; end
16
+ def description
17
+ return 'Email returned due to system error on the remote host'
18
+ end
16
19
 
17
20
  # Try to match that the given text and regular expressions
18
21
  # @param [String] argv1 String to be matched with regular expressions
@@ -10,6 +10,9 @@ module Sisimai
10
10
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SystemFull.pm
11
11
  class << self
12
12
  def text; return 'systemfull'; end
13
+ def description
14
+ return "Email rejected due to a destination mail server's disk is full"
15
+ end
13
16
 
14
17
  # Try to match that the given text and regular expressions
15
18
  # @param [String] argv1 String to be matched with regular expressions
@@ -13,6 +13,9 @@ module Sisimai
13
13
  # Imported from p5-Sisimail/lib/Sisimai/Reason/TooManyConn.pm
14
14
  class << self
15
15
  def text; return 'toomanyconn'; end
16
+ def description
17
+ return 'SMTP connection rejected temporarily due to too many concurrency connections to the remote host'
18
+ end
16
19
 
17
20
  # Try to match that the given text and regular expressions
18
21
  # @param [String] argv1 String to be matched with regular expressions
@@ -0,0 +1,18 @@
1
+ module Sisimai
2
+ module Reason
3
+ # Sisimai::Reason::Undefined is for only returning text and description.
4
+ # This class is called only from Sisimai.reason method.
5
+ module Undefined
6
+ # Imported from p5-Sisimail/lib/Sisimai/Reason/Undefined.pm
7
+ class << self
8
+ def text; return 'undefined'; end
9
+ def description
10
+ return 'Sisimai could not detect an error reason'
11
+ end
12
+ def match; return nil; end
13
+ def true(*); return nil; end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -17,6 +17,9 @@ module Sisimai
17
17
  # Imported from p5-Sisimail/lib/Sisimai/Reason/UserUnknown.pm
18
18
  class << self
19
19
  def text; return 'userunknown'; end
20
+ def description
21
+ return "Email rejected due to a local part of a recipient's email address does not exist"
22
+ end
20
23
 
21
24
  # Try to match that the given text and regular expressions
22
25
  # @param [String] argv1 String to be matched with regular expressions
@@ -0,0 +1,18 @@
1
+ module Sisimai
2
+ module Reason
3
+ # Sisimai::Reason::Vacation is for only returning text and description.
4
+ # This class is called only from Sisimai.reason method.
5
+ module Vacation
6
+ # Imported from p5-Sisimail/lib/Sisimai/Reason/Vacation.pm
7
+ class << self
8
+ def text; return 'vacation'; end
9
+ def description
10
+ return 'Email replied automatically due to a recipient is out of office'
11
+ end
12
+ def match; return nil; end
13
+ def true(*); return nil; end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -42,10 +42,7 @@ module Sisimai
42
42
  :error => %r/\A(?:[45]\d\d[ \t]+|[<][^@]+[@][^@]+[>]:?[ \t]+)/i,
43
43
  :command => %r/[ ](RCPT|MAIL|DATA)[ ]+command\b/,
44
44
  }
45
-
46
45
  Indicators = Sisimai::MTA.INDICATORS
47
- LongFields = Sisimai::RFC5322.LONGFIELDS
48
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
49
46
 
50
47
  def description; 'Fallback Module for MTAs'; end
51
48
  def smtpagent; 'RFC3464'; end
@@ -71,13 +68,12 @@ module Sisimai
71
68
  require 'sisimai/mda'
72
69
  require 'sisimai/address'
73
70
 
74
- dscontents = []; dscontents << Sisimai::MTA.DELIVERYSTATUS
71
+ dscontents = [Sisimai::MTA.DELIVERYSTATUS]
75
72
  hasdivided = mbody.split("\n")
76
73
  havepassed = ['']
77
74
  scannedset = Sisimai::MDA.scan(mhead, mbody)
78
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
79
- rfc822part = '' # (String) message/rfc822-headers part
80
- previousfn = '' # (String) Previous field name
75
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
76
+ blanklines = 0 # (Integer) The number of blank lines
81
77
  readcursor = 0 # (Integer) Points the current cursor position
82
78
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
83
79
  connheader = {
@@ -89,12 +85,13 @@ module Sisimai
89
85
 
90
86
  hasdivided.each do |e|
91
87
  # Save the current line for the next loop
92
- havepassed << e; p = havepassed[-2]
88
+ havepassed << e
89
+ p = havepassed[-2]
93
90
 
94
91
  if readcursor == 0
95
92
  # Beginning of the bounce message or delivery status part
96
93
  if e =~ Re1[:begin]
97
- readcursor |= Indicators[:'deliverystatus']
94
+ readcursor |= Indicators[:deliverystatus]
98
95
  next
99
96
  end
100
97
  end
@@ -109,35 +106,21 @@ module Sisimai
109
106
 
110
107
  if readcursor & Indicators[:'message-rfc822'] > 0
111
108
  # After "message/rfc822"
112
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
113
- # Get required headers only
114
- lhs = cv[1].downcase
115
- previousfn = ''
116
- next unless RFC822Head.key?(lhs)
117
-
118
- previousfn = lhs
119
- rfc822part += e + "\n"
120
-
121
- elsif e =~ /\A[ \t]+/
122
- # Continued line from the previous line
123
- next if rfc822next[previousfn]
124
- rfc822part += e + "\n" if LongFields.key?(previousfn)
125
-
126
- else
127
- # Check the end of headers in rfc822 part
128
- next unless LongFields.key?(previousfn)
129
- next if e.size > 0
130
- rfc822next[previousfn] = true
109
+ if e.empty?
110
+ blanklines += 1
111
+ break if blanklines > 1
112
+ next
131
113
  end
114
+ rfc822list << e
132
115
 
133
116
  else
134
117
  # Before "message/rfc822"
135
- next unless readcursor & Indicators[:'deliverystatus'] > 0
118
+ next unless readcursor & Indicators[:deliverystatus] > 0
136
119
  next unless e.size > 0
137
120
 
138
121
  v = dscontents[-1]
139
122
  if cv = e.match(/\A(?:[Ff]inal|[Oo]riginal)-[Rr]ecipient:[ ]*(?:RFC|rfc)822;[ ]*([^ ]+)\z/) ||
140
- cv = e.match(/\A(?:[Ff]inal|[Oo]riginal)-[Rr]ecipient:[ ]*([^ ]+)\z/)
123
+ e.match(/\A(?:[Ff]inal|[Oo]riginal)-[Rr]ecipient:[ ]*([^ ]+)\z/)
141
124
  # 2.3.2 Final-Recipient field
142
125
  # The Final-Recipient field indicates the recipient for which this set
143
126
  # of per-recipient fields applies. This field MUST be present in each
@@ -476,19 +459,11 @@ module Sisimai
476
459
  if cv = e['diagnosis'].match(Re1[:command])
477
460
  e['command'] = cv[1]
478
461
  end
479
-
480
- if mhead['received'].size > 0
481
- # Get localhost and remote host name from Received header.
482
- r0 = mhead['received']
483
- %w|lhost rhost|.each { |a| e[a] ||= '' }
484
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
485
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
486
- end
487
-
488
462
  e['date'] ||= mhead['date']
489
- e['spec'] ||= 'SMTP'
490
463
  e.each_key { |a| e[a] ||= '' }
491
464
  end
465
+
466
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
492
467
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
493
468
  end
494
469