sisimai 5.4.1-java → 5.6.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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codecovio.yml +1 -1
  3. data/.github/workflows/rake-test.yml +1 -1
  4. data/ChangeLog.md +56 -0
  5. data/LICENSE +1 -1
  6. data/Makefile +2 -4
  7. data/README-JA.md +29 -23
  8. data/README.md +30 -24
  9. data/lib/sisimai/address.rb +92 -44
  10. data/lib/sisimai/arf.rb +7 -8
  11. data/lib/sisimai/datetime.rb +2 -2
  12. data/lib/sisimai/fact/json.rb +1 -2
  13. data/lib/sisimai/fact/yaml.rb +1 -2
  14. data/lib/sisimai/fact.rb +76 -36
  15. data/lib/sisimai/lda.rb +2 -2
  16. data/lib/sisimai/lhost/activehunter.rb +4 -5
  17. data/lib/sisimai/lhost/amazonses.rb +4 -5
  18. data/lib/sisimai/lhost/apachejames.rb +2 -2
  19. data/lib/sisimai/lhost/biglobe.rb +6 -6
  20. data/lib/sisimai/lhost/courier.rb +7 -7
  21. data/lib/sisimai/lhost/domino.rb +6 -6
  22. data/lib/sisimai/lhost/dragonfly.rb +5 -5
  23. data/lib/sisimai/lhost/einsundeins.rb +5 -5
  24. data/lib/sisimai/lhost/exchange2003.rb +7 -7
  25. data/lib/sisimai/lhost/exchange2007.rb +5 -5
  26. data/lib/sisimai/lhost/exim.rb +13 -15
  27. data/lib/sisimai/lhost/ezweb.rb +3 -2
  28. data/lib/sisimai/lhost/fml.rb +9 -9
  29. data/lib/sisimai/lhost/gmail.rb +9 -9
  30. data/lib/sisimai/lhost/gmx.rb +3 -3
  31. data/lib/sisimai/lhost/googlegroups.rb +6 -7
  32. data/lib/sisimai/lhost/googleworkspace.rb +5 -6
  33. data/lib/sisimai/lhost/imailserver.rb +4 -4
  34. data/lib/sisimai/lhost/kddi.rb +4 -4
  35. data/lib/sisimai/lhost/mailfoundry.rb +3 -3
  36. data/lib/sisimai/lhost/{mailmarshalsmtp.rb → mailmarshal.rb} +5 -5
  37. data/lib/sisimai/lhost/messagingserver.rb +8 -8
  38. data/lib/sisimai/lhost/mfilter.rb +8 -4
  39. data/lib/sisimai/lhost/mimecast.rb +105 -0
  40. data/lib/sisimai/lhost/notes.rb +5 -5
  41. data/lib/sisimai/lhost/opensmtpd.rb +5 -5
  42. data/lib/sisimai/lhost/postfix.rb +38 -32
  43. data/lib/sisimai/lhost/qmail.rb +11 -11
  44. data/lib/sisimai/lhost/sendmail.rb +13 -13
  45. data/lib/sisimai/lhost/{interscanmss.rb → trendmicro.rb} +8 -9
  46. data/lib/sisimai/lhost/v5sendmail.rb +7 -7
  47. data/lib/sisimai/lhost/verizon.rb +3 -3
  48. data/lib/sisimai/lhost/x1.rb +7 -4
  49. data/lib/sisimai/lhost/x2.rb +40 -12
  50. data/lib/sisimai/lhost/x3.rb +3 -3
  51. data/lib/sisimai/lhost/x6.rb +2 -2
  52. data/lib/sisimai/lhost/zoho.rb +5 -5
  53. data/lib/sisimai/lhost.rb +18 -17
  54. data/lib/sisimai/mail/maildir.rb +4 -4
  55. data/lib/sisimai/mail/mbox.rb +4 -4
  56. data/lib/sisimai/mail/memory.rb +1 -1
  57. data/lib/sisimai/mail/stdin.rb +2 -2
  58. data/lib/sisimai/message.rb +36 -34
  59. data/lib/sisimai/order.rb +5 -4
  60. data/lib/sisimai/reason/authfailure.rb +10 -14
  61. data/lib/sisimai/reason/badreputation.rb +8 -8
  62. data/lib/sisimai/reason/blocked.rb +58 -83
  63. data/lib/sisimai/reason/contenterror.rb +15 -10
  64. data/lib/sisimai/reason/{mesgtoobig.rb → emailtoolarge.rb} +23 -26
  65. data/lib/sisimai/reason/expired.rb +17 -24
  66. data/lib/sisimai/reason/failedstarttls.rb +1 -1
  67. data/lib/sisimai/reason/filtered.rb +14 -18
  68. data/lib/sisimai/reason/hasmoved.rb +3 -2
  69. data/lib/sisimai/reason/hostunknown.rb +18 -21
  70. data/lib/sisimai/reason/mailboxfull.rb +28 -50
  71. data/lib/sisimai/reason/mailererror.rb +1 -1
  72. data/lib/sisimai/reason/networkerror.rb +17 -17
  73. data/lib/sisimai/reason/norelaying.rb +20 -20
  74. data/lib/sisimai/reason/notaccept.rb +7 -10
  75. data/lib/sisimai/reason/notcompliantrfc.rb +6 -10
  76. data/lib/sisimai/reason/policyviolation.rb +12 -28
  77. data/lib/sisimai/reason/ratelimited.rb +62 -0
  78. data/lib/sisimai/reason/rejected.rb +46 -58
  79. data/lib/sisimai/reason/requireptr.rb +14 -26
  80. data/lib/sisimai/reason/securityerror.rb +14 -20
  81. data/lib/sisimai/reason/spamdetected.rb +52 -102
  82. data/lib/sisimai/reason/suspend.rb +27 -24
  83. data/lib/sisimai/reason/systemerror.rb +20 -24
  84. data/lib/sisimai/reason/systemfull.rb +2 -2
  85. data/lib/sisimai/reason/userunknown.rb +82 -114
  86. data/lib/sisimai/reason/vacation.rb +1 -1
  87. data/lib/sisimai/reason/virusdetected.rb +7 -9
  88. data/lib/sisimai/reason.rb +26 -26
  89. data/lib/sisimai/rfc1123.rb +58 -18
  90. data/lib/sisimai/rfc1894.rb +6 -8
  91. data/lib/sisimai/rfc2045.rb +25 -13
  92. data/lib/sisimai/rfc3464/thirdparty.rb +2 -3
  93. data/lib/sisimai/rfc3464.rb +6 -6
  94. data/lib/sisimai/rfc3834.rb +18 -8
  95. data/lib/sisimai/rfc5322.rb +9 -9
  96. data/lib/sisimai/rfc791.rb +2 -2
  97. data/lib/sisimai/rhost/aol.rb +4 -1
  98. data/lib/sisimai/rhost/apple.rb +15 -11
  99. data/lib/sisimai/rhost/cloudflare.rb +2 -0
  100. data/lib/sisimai/rhost/cox.rb +31 -25
  101. data/lib/sisimai/rhost/facebook.rb +24 -18
  102. data/lib/sisimai/rhost/franceptt.rb +92 -38
  103. data/lib/sisimai/rhost/godaddy.rb +34 -7
  104. data/lib/sisimai/rhost/google.rb +69 -70
  105. data/lib/sisimai/rhost/gsuite.rb +1 -1
  106. data/lib/sisimai/rhost/iua.rb +1 -1
  107. data/lib/sisimai/rhost/kddi.rb +1 -1
  108. data/lib/sisimai/rhost/messagelabs.rb +160 -2
  109. data/lib/sisimai/rhost/microsoft.rb +154 -107
  110. data/lib/sisimai/rhost/mimecast.rb +64 -55
  111. data/lib/sisimai/rhost/nttdocomo.rb +70 -90
  112. data/lib/sisimai/rhost/outlook.rb +1 -1
  113. data/lib/sisimai/rhost/spectrum.rb +8 -8
  114. data/lib/sisimai/rhost/tencent.rb +12 -13
  115. data/lib/sisimai/rhost/yahooinc.rb +9 -10
  116. data/lib/sisimai/rhost/zoho.rb +72 -0
  117. data/lib/sisimai/rhost.rb +4 -3
  118. data/lib/sisimai/smtp/command.rb +4 -2
  119. data/lib/sisimai/smtp/reply.rb +11 -4
  120. data/lib/sisimai/smtp/status.rb +67 -98
  121. data/lib/sisimai/smtp/transcript.rb +3 -3
  122. data/lib/sisimai/string.rb +4 -23
  123. data/lib/sisimai/version.rb +1 -1
  124. data/lib/sisimai.rb +1 -1
  125. data/set-of-emails/maildir/bsd/lhost-exim-56.eml +40 -40
  126. data/set-of-emails/maildir/bsd/lhost-mfilter-05.eml +41 -0
  127. data/set-of-emails/maildir/bsd/lhost-mimecast-01.eml +46 -0
  128. data/set-of-emails/maildir/bsd/lhost-mimecast-02.eml +59 -0
  129. data/set-of-emails/maildir/bsd/lhost-postfix-79.eml +81 -0
  130. data/set-of-emails/maildir/bsd/lhost-postfix-80.eml +84 -0
  131. data/set-of-emails/maildir/bsd/lhost-x1-03.eml +26 -0
  132. data/set-of-emails/maildir/bsd/lhost-x1-04.eml +45 -0
  133. data/set-of-emails/maildir/bsd/lhost-x2-07.eml +30 -0
  134. data/set-of-emails/maildir/bsd/rfc3464-66.eml +170 -0
  135. data/set-of-emails/maildir/bsd/rfc3834-06.eml +59 -0
  136. data/set-of-emails/maildir/bsd/rhost-zoho-01.eml +88 -0
  137. data/set-of-emails/maildir/bsd/rhost-zoho-02.eml +86 -0
  138. data/set-of-emails/maildir/bsd/rhost-zoho-03.eml +87 -0
  139. data/set-of-emails/maildir/bsd/rhost-zoho-04.eml +86 -0
  140. data/set-of-emails/maildir/not/rb-issue-368-bug.eml +39 -0
  141. data/sisimai-java.gemspec +1 -1
  142. data/sisimai.gemspec +1 -1
  143. metadata +28 -13
  144. data/lib/sisimai/reason/exceedlimit.rb +0 -47
  145. data/lib/sisimai/reason/speeding.rb +0 -47
  146. data/lib/sisimai/reason/toomanyconn.rb +0 -59
  147. /data/set-of-emails/maildir/bsd/{lhost-mailmarshalsmtp-02.eml → lhost-mailmarshal-02.eml} +0 -0
  148. /data/set-of-emails/maildir/bsd/{lhost-interscanmss-01.eml → lhost-trendmicro-01.eml} +0 -0
  149. /data/set-of-emails/maildir/bsd/{lhost-interscanmss-02.eml → lhost-trendmicro-02.eml} +0 -0
  150. /data/set-of-emails/maildir/bsd/{lhost-interscanmss-03.eml → lhost-trendmicro-03.eml} +0 -0
@@ -494,10 +494,10 @@ module Sisimai
494
494
  '4.1.7' => 'rejected', # Bad sender's mailbox address syntax
495
495
  '4.1.8' => 'rejected', # Bad sender's system address
496
496
  '4.1.9' => 'systemerror', # Message relayed to non-compliant mailer
497
- '4.2.1' => 'blocked', # Mailbox disabled, not accepting messages
497
+ '4.2.1' => 'suspend', # Mailbox disabled, not accepting messages
498
498
  '4.2.2' => 'mailboxfull', # Mailbox full
499
- '4.2.3' => 'exceedlimit', # Message length exceeds administrative limit
500
- '4.2.4' => 'filtered', # Mailing list expansion problem
499
+ '4.2.3' => 'emailtoolarge', # Message length exceeds administrative limit
500
+ '4.2.4' => 'systemerror', # Mailing list expansion problem
501
501
  # '4.3.0' => 'systemerror', # Other or undefined mail system status
502
502
  '4.3.1' => 'systemfull', # Mail system full
503
503
  '4.3.2' => 'notaccept', # System not accepting network messages
@@ -513,20 +513,20 @@ module Sisimai
513
513
  '4.4.7' => 'expired', # Delivery time expired
514
514
  '4.4.8' => 'networkerror', # Retry on IPv4
515
515
  # '4.5.0' => 'networkerror', # Other or undefined protocol status
516
- '4.5.3' => 'systemerror', # Too many recipients
516
+ '4.5.3' => 'ratelimited', # Too many recipients
517
517
  '4.5.5' => 'systemerror', # Wrong protocol version
518
518
  '4.6.0' => 'contenterror', # Other or undefined media error
519
519
  '4.6.2' => 'contenterror', # Conversion required and prohibited
520
520
  '4.6.5' => 'contenterror', # Conversion Failed
521
521
  # :'4.7.0' => 'securityerror', # Other or undefined security status
522
522
  '4.7.1' => 'blocked', # Delivery not authorized, message refused
523
- '4.7.2' => 'blocked', # Mailing list expansion prohibited
523
+ '4.7.2' => 'rejected', # Mailing list expansion prohibited
524
524
  '4.7.5' => 'securityerror', # Cryptographic failure
525
525
  '4.7.6' => 'securityerror', # Cryptographic algorithm not supported
526
526
  '4.7.7' => 'securityerror', # Message integrity failure
527
527
  '4.7.12' => 'securityerror', # A password transition is needed
528
528
  '4.7.15' => 'securityerror', # Priority Level is too low
529
- '4.7.16' => 'mesgtoobig', # Message is too big for the specified priority
529
+ '4.7.16' => 'emailtoolarge', # Message is too big for the specified priority
530
530
  '4.7.24' => 'authfailure ', # SPF validation error
531
531
  '4.7.25' => 'requireptr', # Reverse DNS validation failed
532
532
  # ---------------------------------------------------------------------------------------
@@ -543,19 +543,19 @@ module Sisimai
543
543
  '5.2.0' => 'filtered', # Other or undefined mailbox status
544
544
  '5.2.1' => 'filtered', # Mailbox disabled, not accepting messages
545
545
  '5.2.2' => 'mailboxfull', # Mailbox full
546
- '5.2.3' => 'exceedlimit', # Message length exceeds administrative limit
547
- '5.2.4' => 'filtered', # Mailing list expansion problem
546
+ '5.2.3' => 'emailtoolarge', # Message length exceeds administrative limit
547
+ '5.2.4' => 'systemerror', # Mailing list expansion problem
548
548
  '5.3.0' => 'systemerror', # Other or undefined mail system status
549
549
  '5.3.1' => 'systemfull', # Mail system full
550
550
  '5.3.2' => 'notaccept', # System not accepting network messages
551
551
  '5.3.3' => 'systemerror', # System not capable of selected features
552
- '5.3.4' => 'mesgtoobig', # Message too big for system
552
+ '5.3.4' => 'emailtoolarge', # Message too big for system
553
553
  '5.3.5' => 'systemerror', # System incorrectly configured
554
554
  '5.4.0' => 'networkerror', # Other or undefined network or routing status
555
555
  '5.4.3' => 'systemerror', # Directory server failure
556
556
  '5.4.4' => 'hostunknown', # Unable to route
557
- '5.5.2' => 'syntaxerror', # If the server cannot BASE64 decode any client response (AUTH)
558
- '5.5.3' => 'toomanyconn', # Too many recipients
557
+ '5.5.2' => 'systemerror', # If the server cannot BASE64 decode any client response (AUTH)
558
+ '5.5.3' => 'ratelimited', # Too many recipients
559
559
  '5.5.4' => 'systemerror', # Invalid command arguments
560
560
  '5.5.5' => 'systemerror', # Wrong protocol version
561
561
  '5.5.6' => 'syntaxerror', # Authentication Exchange line is too long
@@ -565,7 +565,7 @@ module Sisimai
565
565
  '5.6.3' => 'contenterror', # Conversion required but not supported
566
566
  '5.6.5' => 'contenterror', # Conversion Failed
567
567
  '5.6.6' => 'contenterror', # Message content not available
568
- '5.6.7' => 'contenterror', # Non-ASCII addresses not permitted for that sender/recipient
568
+ '5.6.7' => 'rejected', # Non-ASCII addresses not permitted for that sender/recipient
569
569
  '5.6.8' => 'contenterror', # UTF-8 string reply is required, but not permitted by the SMTP client
570
570
  '5.6.9' => 'contenterror', # UTF-8 header message cannot be transferred to one or more recipients
571
571
  '5.7.0' => 'securityerror', # Other or undefined security status
@@ -583,10 +583,10 @@ module Sisimai
583
583
  '5.7.13' => 'suspend', # User Account Disabled
584
584
  '5.7.14' => 'securityerror', # Trust relationship required
585
585
  '5.7.15' => 'securityerror', # Priority Level is too low
586
- '5.7.16' => 'mesgtoobig', # Message is too big for the specified priority
586
+ '5.7.16' => 'emailtoolarge', # Message is too big for the specified priority
587
587
  '5.7.17' => 'hasmoved', # Mailbox owner has changed
588
588
  '5.7.18' => 'hasmoved', # Domain owner has changed
589
- '5.7.19' => 'securityerror', # RRVS test cannot be completed
589
+ '5.7.19' => 'systemerror', # RRVS test cannot be completed
590
590
  '5.7.20' => 'authfailure', # No passing DKIM signature found
591
591
  '5.7.21' => 'authfailure', # No acceptable DKIM signature found
592
592
  '5.7.22' => 'authfailure', # No valid author-matched DKIM signature found
@@ -601,76 +601,37 @@ module Sisimai
601
601
  }.freeze
602
602
 
603
603
  InternalCode = {
604
- :temporary => {
605
- 'authfailure' => '4.0.926',
606
- 'badreputation' => '4.0.975',
607
- 'blocked' => '4.0.971',
608
- 'contenterror' => '4.0.960',
609
- 'exceedlimit' => '4.0.923',
610
- 'expired' => '4.0.947',
611
- 'failedstarttls' => '4.0.976',
612
- 'filtered' => '4.0.924',
613
- # 'hasmoved' => '4.0.916',
614
- # 'hostunknown' => '4.0.912',
615
- 'mailboxfull' => '4.0.922',
616
- 'mailererror' => '4.0.939',
617
- 'mesgtoobig' => '4.0.934',
618
- 'networkerror' => '4.0.944',
619
- 'norelaying' => '4.0.909',
620
- 'notaccept' => '4.0.932',
621
- 'notcompliantrfc' => '4.0.974',
622
- 'onhold' => '4.0.901',
623
- 'policyviolaton' => '4.0.972',
624
- 'rejected' => '4.0.918',
625
- 'requireptr' => '4.0.973',
626
- 'securityerror' => '4.0.970',
627
- 'spamdetected' => '4.0.980',
628
- 'speeding' => '4.0.946',
629
- 'suppressed' => '4.0.903',
630
- 'suspend' => '4.0.921',
631
- 'systemerror' => '4.0.930',
632
- 'systemfull' => '4.0.931',
633
- 'syntaxerror' => '4.0.902',
634
- 'toomanyconn' => '4.0.945',
635
- # 'userunknown' => '4.0.911',
636
- 'undefined' => '4.0.900',
637
- 'virusdetected' => '4.0.981',
638
- },
639
- :permanent => {
640
- 'authfailure' => '5.0.926',
641
- 'badreputation' => '5.0.975',
642
- 'blocked' => '5.0.971',
643
- 'contenterror' => '5.0.960',
644
- 'exceedlimit' => '5.0.923',
645
- 'expired' => '5.0.947',
646
- 'failedstarttls' => '5.0.976',
647
- 'filtered' => '5.0.910',
648
- 'hasmoved' => '5.0.916',
649
- 'hostunknown' => '5.0.912',
650
- 'mailboxfull' => '5.0.922',
651
- 'mailererror' => '5.0.939',
652
- 'mesgtoobig' => '5.0.934',
653
- 'networkerror' => '5.0.944',
654
- 'norelaying' => '5.0.909',
655
- 'notaccept' => '5.0.932',
656
- 'notcompliantrfc' => '5.0.974',
657
- 'onhold' => '5.0.901',
658
- 'policyviolation' => '5.0.972',
659
- 'rejected' => '5.0.918',
660
- 'requireptr' => '5.0.973',
661
- 'securityerror' => '5.0.970',
662
- 'spamdetected' => '5.0.980',
663
- 'speeding' => '5.0.946',
664
- 'suppressed' => '5.0.903',
665
- 'suspend' => '5.0.921',
666
- 'systemerror' => '5.0.930',
667
- 'systemfull' => '5.0.931',
668
- 'syntaxerror' => '5.0.902',
669
- 'toomanyconn' => '5.0.945',
670
- 'userunknown' => '5.0.911',
671
- 'undefined' => '5.0.900',
672
- 'virusdetected' => '5.0.981',
673
- },
604
+ 'authfailure' => ['5.9.130', '4.9.130'],
605
+ 'badreputation' => ['5.9.132', '4.9.132'],
606
+ 'blocked' => ['5.9.134', '4.9.134'],
607
+ 'contenterror' => ['5.9.160', '4.9.160'],
608
+ 'emailtoolarge' => ['5.9.161', '4.9.161'],
609
+ 'expired' => ['5.9.340', '4.9.340'],
610
+ 'failedstarttls' => ['5.9.350', '4.9.350'],
611
+ 'filtered' => ['5.9.210', '4.9.210'],
612
+ 'hasmoved' => ['5.9.211', ''],
613
+ 'hostunknown' => ['5.9.212', ''],
614
+ 'mailboxfull' => ['5.9.220', '4.9.220'],
615
+ 'mailererror' => ['5.9.230', '4.9.230'],
616
+ 'networkerror' => ['5.9.341', '4.9.341'],
617
+ 'norelaying' => ['5.9.214', '4.9.214'],
618
+ 'notaccept' => ['5.9.215', '4.9.215'],
619
+ 'notcompliantrfc' => ['5.9.162', '4.9.162'],
620
+ 'onhold' => ['5.9.301', '4.9.301'],
621
+ 'policyviolation' => ['5.9.371', '4.9.371'],
622
+ 'ratelimited' => ['5.9.131', '4.9.131'],
623
+ 'rejected' => ['5.9.110', '4.9.110'],
624
+ 'requireptr' => ['5.9.133', '4.9.133'],
625
+ 'securityerror' => ['5.9.370', '4.9.370'],
626
+ 'spamdetected' => ['5.9.164', '4.9.164'],
627
+ 'suppressed' => ['5.9.310', '4.9.310'],
628
+ 'suspend' => ['5.9.221', '4.9.221'],
629
+ 'syntaxerror' => ['5.9.351', '4.9.351'],
630
+ 'systemerror' => ['5.9.231', '4.9.231'],
631
+ 'systemfull' => ['5.9.232', '4.9.232'],
632
+ 'undefined' => ['5.9.300', '4.9.300'],
633
+ 'userunknown' => ['5.9.213', ''],
634
+ 'virusdetected' => ['5.9.165', '4.9.165'],
674
635
  }.freeze
675
636
 
676
637
  # Convert from the reason string to the internal status code
@@ -679,12 +640,11 @@ module Sisimai
679
640
  # true: Temporary error
680
641
  # @return [String] DSN or an empty string if the 1st argument is missing
681
642
  # @see name
682
- def code(argv1 = nil, argv2 = false)
683
- return "" if argv1.to_s.empty?
643
+ def code(argv1 = "", argv2 = false)
644
+ return "" if argv1.empty?
684
645
 
685
- table = argv2 ? InternalCode[:temporary] : InternalCode[:permanent]
686
- code0 = table[argv1] || InternalCode[:permanent][argv1] || nil
687
- return code0
646
+ pairs = InternalCode[argv1]; return "" if pairs.nil?
647
+ return argv2 ? pairs[1] : pairs[0]
688
648
  end
689
649
 
690
650
  # Convert from the status code to the reason string
@@ -692,7 +652,7 @@ module Sisimai
692
652
  # @return [String] Reason name or an empty string
693
653
  # @see code
694
654
  def name(argv1 = nil)
695
- return "" unless Sisimai::SMTP::Status.test(argv1.to_s)
655
+ return "" if Sisimai::SMTP::Status.test(argv1.to_s) == false
696
656
  return StandardCode[argv1] || ""
697
657
  end
698
658
 
@@ -706,7 +666,7 @@ module Sisimai
706
666
 
707
667
  token = []
708
668
  argv1.split('.').each { |e| token << e.to_i }
709
- return false unless token.size == 3
669
+ return false if token.size != 3
710
670
  return false if token[0] < 2 || token[0] == 3 || token[0] > 5
711
671
  return false if token[1] < 0 || token[1] > 7
712
672
  return false if token[2] < 0
@@ -755,7 +715,7 @@ module Sisimai
755
715
 
756
716
  lookingfor.sort_by(&:first).each do |e|
757
717
  # Try to find an SMTP Status Code from the given string
758
- indexofees = esmtperror.index(e[1], e[0]); next unless indexofees
718
+ indexofees = esmtperror.index(e[1], e[0]); next if indexofees.nil?
759
719
  characters = [esmtperror[indexofees - 1, 1].ord] # [0] The previous character of the status
760
720
  [2, 3].each do |i|
761
721
  # [1] The value of the "Subject", "5.[7].261"
@@ -788,7 +748,7 @@ module Sisimai
788
748
  next if characters[3] < 48 || characters[3] > 57 # The 1st digit of the detail is not a number
789
749
  readbuffer << characters[3].chr
790
750
 
791
- if readbuffer.index('.0.0') || readbuffer == '4.4.7'
751
+ if Sisimai::SMTP::Status.is_ambiguous(readbuffer) || readbuffer == "4.4.7"
792
752
  # Find another status code except *.0.0, 4.4.7
793
753
  anotherone = readbuffer
794
754
  next
@@ -827,11 +787,11 @@ module Sisimai
827
787
  # @return [String] The preferred value
828
788
  # @since v5.0.0
829
789
  def prefer(argv0 = nil, argv1 = nil, argv2 = nil)
830
- return argv1 unless argv0; return argv1 unless argv0.size > 4
831
- return argv0 unless argv1; return argv0 unless argv1.size > 4
790
+ return argv1 if argv0.nil?; return argv1 if argv0.size < 5
791
+ return argv0 if argv1.nil?; return argv0 if argv1.size < 5
832
792
 
833
793
  statuscode = argv0
834
- codeinmesg = argv1
794
+ codeinmesg = argv1; return codeinmesg if statuscode.index(".9.") == 1
835
795
  esmtpreply = argv2 || '000'
836
796
  the1stchar = {
837
797
  'field' => statuscode[0, 1].to_i,
@@ -883,14 +843,23 @@ module Sisimai
883
843
  return statuscode
884
844
  end
885
845
 
886
- # is_explicit() returns 0 when the argument is empty or is an internal code
846
+ # is_explicit() returns false when the argument is empty or is an internal code
887
847
  # @param string argv1 Status code
888
848
  # @return bool false: The delivery status code is not explicit
889
849
  def is_explicit(argv1 = '')
890
850
  return false if argv1.nil? || argv1.empty?
891
- return false if argv1.size == 7 && argv1.start_with?("5.0.9", "4.0.9")
851
+ return false if argv1.size == 7 && argv1.start_with?("5.9.", "4.9.")
892
852
  return true
893
853
  end
854
+
855
+ # is_ambiguous() returns true when the argument is not empty and ends with ".0.0".
856
+ # @param string argv1 Status code
857
+ # @return bool false: The delivery status code is not ambiguous
858
+ def is_ambiguous(argv1 = '')
859
+ return true if argv1.nil? || argv1.empty?
860
+ return true if argv1.size == 5 && argv1.end_with?(".0.0")
861
+ return false
862
+ end
894
863
  end
895
864
  end
896
865
  end
@@ -17,8 +17,8 @@ module Sisimai
17
17
  return nil if argv0.size == 0
18
18
 
19
19
  # 1. Replace label strings of SMTP client/server at the each line
20
- argv0.gsub!(/^[ ]+#{argv1}\s+/m, '>>> '); return nil unless argv0.include?('>>> ')
21
- argv0.gsub!(/^[ ]+#{argv2}\s+/m, '<<< '); return nil unless argv0.include?('<<< ')
20
+ argv0.gsub!(/^[ ]+#{argv1}\s+/m, '>>> '); return nil if argv0.include?('>>> ') == false
21
+ argv0.gsub!(/^[ ]+#{argv2}\s+/m, '<<< '); return nil if argv0.include?('<<< ') == false
22
22
 
23
23
  # 2. Remove strings until the first '<<<' or '>>>'
24
24
  esmtp = []
@@ -96,7 +96,7 @@ module Sisimai
96
96
  end
97
97
  else
98
98
  # SMTP server sent a response "<<< response text"
99
- p = e.index('<<< '); next unless p == 0
99
+ p = e.index('<<< '); next if p.nil? && p != 0
100
100
  e = e[4, e.size].sub(/\A<<<[ ]/, '')
101
101
 
102
102
  if cv = e.match(/\A([2-5]\d\d)[ ]/) then cx['response']['reply'] = cv[1] end
@@ -7,30 +7,13 @@ module Sisimai
7
7
  body: %r|<head>.+</head>.*<body[ >].+</body>|im,
8
8
  }
9
9
 
10
- # Create message token from addresser and recipient
11
- # @param [String] addr1 Sender address
12
- # @param [String] addr2 Recipient address
13
- # @param [Integer] epoch Machine time of the email bounce
14
- # @return [String] Message token(MD5 hex digest) or blank(failed to create token)
15
- # @see http://en.wikipedia.org/wiki/ASCII
16
- def token(addr1, addr2, epoch)
17
- return "" unless addr1.is_a?(::String)
18
- return "" unless addr2.is_a?(::String)
19
- return "" unless epoch.is_a?(Integer)
20
- return "" if addr1.empty? || addr2.empty?
21
-
22
- # Format: STX(0x02) Sender-Address RS(0x1e) Recipient-Address ETX(0x03)
23
- require 'digest/sha1'
24
- return Digest::SHA1.hexdigest(sprintf("\x02%s\x1e%s\x1e%d\x03", addr1.downcase, addr2.downcase, epoch))
25
- end
26
-
27
10
  # The argument is 8-bit text or not
28
11
  # @param [String] argvs Any string to be checked
29
12
  # @return [Boolean] false: ASCII Characters only, true: Including 8-bit character
30
13
  def is_8bit(argvs)
31
14
  v = argvs.to_s
32
15
  return false if v.empty?
33
- return true unless v =~ /\A[\x00-\x7f]*\z/
16
+ return true if v !~ /\A[\x00-\x7f]*\z/
34
17
  return false
35
18
  end
36
19
 
@@ -40,7 +23,7 @@ module Sisimai
40
23
  # @example Clean up text
41
24
  # sweep(' neko ') #=> 'neko'
42
25
  def sweep(argv1)
43
- return argv1 unless argv1.is_a?(::String)
26
+ return argv1 if argv1.is_a?(::String) == false
44
27
  argv1 = argv1.chomp.squeeze(' ').strip
45
28
  argv1 = argv1.sub(/ [-]{2,}[^ ].+\z/, '')
46
29
  return argv1
@@ -52,16 +35,14 @@ module Sisimai
52
35
  # @return [Boolean]
53
36
  # @since v5.0.0
54
37
  def aligned(argv1, argv2)
55
- return false if argv1.to_s.empty?
56
- return false unless argv2.is_a? Array
57
- return false unless argv2.size > 1
38
+ return false if argv1.to_s.empty? || argv2.is_a?(Array) == false || argv2.size < 2
58
39
 
59
40
  align = -1
60
41
  right = 0
61
42
  argv2.each do |e|
62
43
  # Get the position of each element in the 1st argument using index()
63
44
  p = argv1.index(e, align + 1)
64
- break unless p # Break this loop when there is no string in the 1st argument
45
+ break if p == nil # Break this loop when there is no string in the 1st argument
65
46
  align = e.length + p - 1 # There is an aligned string in the 1st argument
66
47
  right += 1
67
48
  end
@@ -1,4 +1,4 @@
1
1
  # Define the version number of Sisimai
2
2
  module Sisimai
3
- VERSION = '5.4.1'.freeze
3
+ VERSION = '5.6.0'.freeze
4
4
  end
data/lib/sisimai.rb CHANGED
@@ -44,7 +44,7 @@ module Sisimai
44
44
  end
45
45
  end
46
46
 
47
- sisi += fact unless fact.empty?
47
+ sisi += fact if fact.empty? == false
48
48
  end
49
49
 
50
50
  return nil if sisi.empty?
@@ -1,40 +1,40 @@
1
- Return-path: <>
2
- Envelope-to: sironeko@node2.example.net
3
- Delivery-date: Thu, 29 Apr 2016 23:34:45 +0900
4
- Received: from mta22.example.com by node2.example.net with local (Exim 4.88)
5
- id nekochan-nyaaan-22
6
- for sironeko@node2.example.net; Thu, 29 Apr 2016 23:34:45 +0900
7
- X-Failed-Recipients: kijitora@example.com
8
- Auto-Submitted: auto-replied
9
- From: Mail Delivery System <Mailer-Daemon@node2.example.net>
10
- To: sironeko@node2.example.net
11
- Subject: Mail delivery failed: returning message to sender
12
- Message-Id: <nekochan-nyaaan-22@node2.example.net>
13
- Date: Thu, 29 Apr 2016 23:34:45 +0900
14
-
15
- This message was created automatically by mail delivery software.
16
-
17
- A message that you sent could not be delivered to one or more of its
18
- recipients. This is a permanent error. The following address(es) failed:
19
-
20
- kijitora@example.com
21
- SMTP error from remote mail server after initial connection:
22
- host email-22.example.net [192.0.2.222]:
23
- 554 neko-22.nyaan.r.example.net :
24
- CAT : neko22 : CAT : You've reached your daily relay quota - 203.0.113.0
25
-
26
- ------ This is a copy of the message, including all the headers. ------
27
-
28
- Return-path: <sironeko@.example.net>
29
- Received: from sironeko by node2.example.net with local (Exim 4.88)
30
- (envelope-from <sironeko@.example.net>)
31
- id nekochan-nyaaan-22
32
- for kijitora@example.com; Thu, 29 Apr 2016 23:34:45 +0900
33
- To: kijitora@example.com
34
- Subject: Nyaan
35
- Message-Id: <nekochan-nyaaan-22@node2.example.net>
36
- From: sironeko@.example.net
37
- Date: Thu, 29 Apr 2016 23:34:45 +0900
38
-
39
- Nyaan
40
-
1
+ Return-path: <>
2
+ Envelope-to: sironeko@node2.example.net
3
+ Delivery-date: Thu, 29 Apr 2016 23:34:45 +0900
4
+ Received: from mta22.example.com by node2.example.net with local (Exim 4.88)
5
+ id nekochan-nyaaan-22
6
+ for sironeko@node2.example.net; Thu, 29 Apr 2016 23:34:45 +0900
7
+ X-Failed-Recipients: kijitora@example.com
8
+ Auto-Submitted: auto-replied
9
+ From: Mail Delivery System <Mailer-Daemon@node2.example.net>
10
+ To: sironeko@node2.example.net
11
+ Subject: Mail delivery failed: returning message to sender
12
+ Message-Id: <nekochan-nyaaan-22@node2.example.net>
13
+ Date: Thu, 29 Apr 2016 23:34:45 +0900
14
+
15
+ This message was created automatically by mail delivery software.
16
+
17
+ A message that you sent could not be delivered to one or more of its
18
+ recipients. This is a permanent error. The following address(es) failed:
19
+
20
+ kijitora@example.com
21
+ SMTP error from remote mail server after initial connection:
22
+ host email-22.example.net [192.0.2.222]:
23
+ 554 neko-22.nyaan.r.example.net :
24
+ CAT : neko22 : CAT : You've reached your daily relay quota - 203.0.113.0
25
+
26
+ ------ This is a copy of the message, including all the headers. ------
27
+
28
+ Return-path: <sironeko@example.net>
29
+ Received: from sironeko by node2.example.net with local (Exim 4.88)
30
+ (envelope-from <sironeko@example.net>)
31
+ id nekochan-nyaaan-22
32
+ for kijitora@example.com; Thu, 29 Apr 2016 23:34:45 +0900
33
+ To: kijitora@example.com
34
+ Subject: Nyaan
35
+ Message-Id: <nekochan-nyaaan-22@node2.example.net>
36
+ From: sironeko@example.net
37
+ Date: Thu, 29 Apr 2016 23:34:45 +0900
38
+
39
+ Nyaan
40
+
@@ -0,0 +1,41 @@
1
+ Return-Path: <>
2
+ X-Original-To: system@errors.example.org
3
+ Delivered-To: system@errors.example.org
4
+ Received: from relay1.example.org (unknown [192.0.2.20])
5
+ by sys.example.org (Postfix) with ESMTPS id zkxVXLYvL8zRVYdx
6
+ for <system@errors.example.org>; Sun, 30 Mar 2025 23:34:55 +0900 (JST)
7
+ Received: from smtpd.relaying.example.jp (ip-192-0-2-2.ap-northeast-1.compute.internal [192.0.2.2])
8
+ by relay1.example.org (Postfix) with ESMTPS id SPCY8TBznXzt2VRQ
9
+ for <nekochan@example.org>; Sun, 30 Mar 2025 23:34:55 +0900 (JST)
10
+ Received: by smtpd.relaying.example.jp (localhost) id SMNgMS1V071253; Sun, 30 Mar 2025 23:34:55 +0900
11
+ Received: from esmtp2.example.co.jp ([192.0.2.25])
12
+ by relay.relaying.example.jp (relayhost) id Jr3FHeoX083118
13
+ Sun, 30 Mar 2025 23:34:54 +0900
14
+ Received: from esmtp2.example.co.jp ([127.0.0.1]) by smtphost with ESMTP; Sun, 30 Mar 2025 23:34:53 +0900
15
+ Reply-To: <>
16
+ X-Mailer: local-mailhub
17
+ Message-Id: <000000000000.00000.00000000.POSTMASTER@EXAMPLE.CO.JP>
18
+ MIME-Version: 1.0
19
+ Content-Type: text/plain; charset="UTF-8"
20
+ Content-Transfer-Encoding: Base64
21
+ From: postmaster <postmaster@example.co.jp>
22
+ To: nekochan@example.org
23
+ Date: Sun, 30 Mar 2025 00:56:39 +0900
24
+ Subject: failure notice
25
+
26
+ 44GT44Gu44Oh44O844Or44Gv44CM44Oh44O844Or44K344Og44OG44Og44CN44GM
27
+ 6Ieq5YuV55qE44Gr55Sf5oiQ44GX44Gm6YCB5L+h44GX44Gm44GE44G+44GZ44CC
28
+ CuODoeODvOODq+OCteODvOODkOODvOOBqOOBrumAmuS/oeS4reOAgeS4i+iomOOB
29
+ rueQhueUseOBq+OCiOOCigrjgZPjga7jg6Hjg7zjg6vjga/pgIHkv6HjgafjgY3j
30
+ gb7jgZvjgpPjgafjgZfjgZ/jgIIKCuS7peS4i+OBruODoeODvOODq+OCouODieOD
31
+ rOOCueOBuOOBrumAgeS/oeOBq+WkseaVl+OBl+OBvuOBl+OBn+OAggpraWppdG9y
32
+ YUBleGFtcGxlLmNvLmpwCgoKLS0tLS0tLXNlcnZlciBtZXNzYWdlCjQ1MiA0LjMu
33
+ MSBJbnN1ZmZpY2llbnQgc3lzdGVtIHJlc291cmNlcyAoVXNlZERpc2tTcGFjZVtE
34
+ OlxQcm9ncmFtIEZpbGVzXE1pY3Jvc29mdFxFeGNoYW5nZSBTZXJ2ZXJcVjE1XFRy
35
+ YW5zcG9ydFJvbGVzXGRhdGFcUXVldWVdKQoKLS0tLS0tLVNNVFAgY29tbWFuZApE
36
+ QVRBCgotLS0tLS0tb3JpZ2luYWwgbWFpbCBpbmZvCkZyb206IG5la29jaGFuQGV4
37
+ YW1wbGUub3JnClN1YmplY3Q6IOODi+ODo+ODvOODs++8nwpEYXRlOiBTYXQsIDI5
38
+ IE1hciAyMDI1IDIzOjUyOjIyICswOTAwCk1lc3NhZ2UtSUQ6IDwwMDAwMDAwMDAy
39
+ MTEuMjIyMjIyMjIyMDAwQGxvY2FsaG9zdD4KQk9EWToKLS0tLS0tLS0tLS0tLS0t
40
+ LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQpOeWFhbgoK
41
+
@@ -0,0 +1,46 @@
1
+ Return-Path: <>
2
+ X-Original-To: neko@error.example.jp
3
+ Delivered-To: neko@error.example.jp
4
+ Received: from smtp.example.jp (unknown [192.0.2.25])
5
+ by eb.example.jp (Postfix) with ESMTPS id X4RDMVtpJ9z25xtV
6
+ for <neko@error.example.jp>; Mon, 29 Apr 2024 18:30:22 +0900 (JST)
7
+ Authentication-Results: eb.example.jp;
8
+ dkim=pass (1024-bit key, unprotected) header.d=ef.example.org header.i=@ef.example.org header.a=rsa-sha256 header.s=mimecast20180622 header.b=e...
9
+ Received: from us-smtp-delivery-225.mimecast.com (ip-192-0-2-125.us-east-1.compute.internal [192.0.2.22])
10
+ by smtp.example.jp (Postfix) with ESMTP id Zgr2Fply9TzPD185
11
+ for <kijitora@example.jp>; Mon, 29 Apr 2024 18:30:22 +0900 (JST)
12
+ Authentication-Results: smtp.example.jp;
13
+ dkim=pass (1024-bit key; unprotected) header.d=ef.example.org header.i=@ef.example.org header.a=rsa-sha256 header.s=mimecast20180622 header.b=e...
14
+ Subject: [Postmaster] Email Delivery Failure
15
+ Message-Id: <0123456789-1102117314000@us-mta-587.us.mimecast.lan>
16
+ Date: Mon, 29 Apr 2024 20:30:00 +1100
17
+ From: "postmaster" <postmaster@ef.example.org>
18
+ To: <kijitora@example.jp>
19
+ Mime-Version: 1.0
20
+ X-MC-System: =UmV0dXJuLVBhdGg6IDw+ClgtT3JpZ2luYWwtVG86IG5la29AZXJyb3IuZXhhbXBs
21
+ X-Mimecast-Originator: <>
22
+ Content-Type: text/plain; charset=UTF-8
23
+ Content-Transfer-Encoding: quoted-printable
24
+
25
+ This is an automated alert notification. Please do not reply.
26
+
27
+ An email that you attempted to send to the following address could not be d=
28
+ elivered:
29
+ -- sabineko@neko.ef.example.org
30
+
31
+ The problem appears to be :
32
+ -- Recipient email address is possibly incorrect
33
+
34
+ Additional information follows :
35
+ -- 5.4.1 Recipient address rejected: Access denied. [QQQQQQE00000000.jpnprd=
36
+ 01.prod.outlook.com 2024-02-19T09:30:25.255Z FFFFFFFFFFEEEEEE]
37
+
38
+ This condition occurred after 1 attempt(s) to deliver over
39
+ a period of 0 hour(s).
40
+
41
+ If you sent the email to multiple recipients, you will receive one
42
+ of these messages for each one which failed delivery, otherwise
43
+ they have been sent.
44
+
45
+ If you require further information, please contact the Service Desk.
46
+
@@ -0,0 +1,59 @@
1
+ Return-Path: <>
2
+ X-Original-To: sisi@errors.rr.example.jp
3
+ Delivered-To: sisi@errors.rr.example.jp
4
+ Received: from smtp.rr.example.jp (unknown [192.0.2.25])
5
+ by be.rr.example.jp (Postfix) with ESMTPS id 86ZvZmL8hKzWT593
6
+ for <sisi@errors.rr.example.jp>; Sat, 8 Feb 2025 20:22:22 +0900 (JST)
7
+ Received: from eu-smtp-delivery-255.mimecast.com (ip-192-0-2-22.ap-northeast-1.compute.internal [192.0.2.22])
8
+ by smtp.rr.example.jp (Postfix) with ESMTP id qQSDNz8RQjzVCWf3
9
+ for <kijitora@rr.example.jp>; Sat, 8 Feb 2025 20:22:21 +0900 (JST)
10
+ Subject: [Postmaster] Email Delivery Failure
11
+ Message-Id: <000000002-1111111110222@uk-mta-64.uk.mimecast.lan>
12
+ Date: Sat, 08 Feb 2025 11:22:30 +0000
13
+ From: Postmaster <postmaster@example.com>
14
+ To: <kijitora@rr.example.jp>
15
+ Mime-Version: 1.0
16
+ X-MC-System: =aHR0cHM6Ly9saWJzaXNpbWFpLm9yZy8K
17
+ X-Mimecast-Originator: <>
18
+ Content-Type: multipart/report; report-type=delivery-status;
19
+ boundary="MCBoundary=_14916154590123456"
20
+
21
+ --MCBoundary=_14916154590123456
22
+ Content-Type: text/plain; charset=UTF-8
23
+ Content-Transfer-Encoding: quoted-printable
24
+
25
+ This is a delivery failure notification message indicating that
26
+ an email you addressed to email address :
27
+ -- sabatora@example.net
28
+
29
+ could not be delivered. The problem appears to be :
30
+ -- Recipient email address is possibly incorrect
31
+
32
+ Additional information follows :
33
+ -- 5.7.54 SMTP; Unable to relay recipient in non-accepted domain
34
+
35
+ This condition occurred after 1 attempt(s) to deliver over
36
+ a period of 0 hour(s).
37
+
38
+ If you sent the email to multiple recipients, you will receive one
39
+ of these messages for each one which failed delivery, otherwise
40
+ they have been sent.
41
+
42
+ --MCBoundary=_14916154590123456
43
+ Content-Type: message/delivery-status; charset=UTF-8
44
+
45
+ DISPLAY_DATE_FORMAT : EEE, dd MMM yyyy HH:mm:ss zzz
46
+ Original-Envelope-Id : 5gENiF_01OCe5ak-neko22
47
+ Reporting-MTA : dns;eu-smtp-inbound-delivery-1.mimecast.com
48
+ Arrival-Date : Sat, 08 Feb 2025 11:22:21 GMT
49
+ Action : failed
50
+ Status : 5.0.0
51
+ Diagnostic-Code : smtp;550 5.7.54 SMTP; Unable to relay recipient in non-accepted domain
52
+ Last-Attempt-Date : Sat, 08 Feb 2025 11:22:28 GMT
53
+ Original-Recipient : rfc/822;sabatora@example.net
54
+ Remote-MTA : example.net
55
+ Final-Recipient : rfc/822;sabatora@example.net
56
+
57
+
58
+ --MCBoundary=_14916154590123456--
59
+