sisimai 4.22.1 → 4.22.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sisimai might be problematic. Click here for more details.

Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +21 -0
  3. data/README-JA.md +2 -2
  4. data/README.md +2 -2
  5. data/lib/sisimai.rb +2 -3
  6. data/lib/sisimai/address.rb +20 -40
  7. data/lib/sisimai/arf.rb +4 -4
  8. data/lib/sisimai/bite.rb +1 -0
  9. data/lib/sisimai/bite/email.rb +3 -4
  10. data/lib/sisimai/bite/email/activehunter.rb +7 -7
  11. data/lib/sisimai/bite/email/amazonses.rb +14 -14
  12. data/lib/sisimai/bite/email/amazonworkmail.rb +7 -7
  13. data/lib/sisimai/bite/email/aol.rb +8 -8
  14. data/lib/sisimai/bite/email/apachejames.rb +7 -7
  15. data/lib/sisimai/bite/email/bigfoot.rb +7 -7
  16. data/lib/sisimai/bite/email/biglobe.rb +7 -7
  17. data/lib/sisimai/bite/email/courier.rb +9 -9
  18. data/lib/sisimai/bite/email/domino.rb +8 -8
  19. data/lib/sisimai/bite/email/einsundeins.rb +7 -7
  20. data/lib/sisimai/bite/email/exchange2003.rb +10 -10
  21. data/lib/sisimai/bite/email/exchange2007.rb +10 -10
  22. data/lib/sisimai/bite/email/exim.rb +18 -19
  23. data/lib/sisimai/bite/email/ezweb.rb +9 -11
  24. data/lib/sisimai/bite/email/facebook.rb +22 -23
  25. data/lib/sisimai/bite/email/gmx.rb +7 -7
  26. data/lib/sisimai/bite/email/google.rb +22 -25
  27. data/lib/sisimai/bite/email/gsuite.rb +17 -19
  28. data/lib/sisimai/bite/email/imailserver.rb +13 -13
  29. data/lib/sisimai/bite/email/interscanmss.rb +7 -7
  30. data/lib/sisimai/bite/email/kddi.rb +7 -7
  31. data/lib/sisimai/bite/email/mailfoundry.rb +6 -6
  32. data/lib/sisimai/bite/email/mailmarshalsmtp.rb +13 -13
  33. data/lib/sisimai/bite/email/mailru.rb +10 -10
  34. data/lib/sisimai/bite/email/mcafee.rb +7 -7
  35. data/lib/sisimai/bite/email/messagelabs.rb +9 -9
  36. data/lib/sisimai/bite/email/messagingserver.rb +8 -8
  37. data/lib/sisimai/bite/email/mfilter.rb +7 -7
  38. data/lib/sisimai/bite/email/mxlogic.rb +9 -9
  39. data/lib/sisimai/bite/email/notes.rb +12 -12
  40. data/lib/sisimai/bite/email/office365.rb +14 -15
  41. data/lib/sisimai/bite/email/opensmtpd.rb +7 -7
  42. data/lib/sisimai/bite/email/outlook.rb +9 -9
  43. data/lib/sisimai/bite/email/postfix.rb +13 -13
  44. data/lib/sisimai/bite/email/qmail.rb +9 -9
  45. data/lib/sisimai/bite/email/receivingses.rb +9 -9
  46. data/lib/sisimai/bite/email/sendgrid.rb +9 -9
  47. data/lib/sisimai/bite/email/sendmail.rb +7 -7
  48. data/lib/sisimai/bite/email/surfcontrol.rb +7 -7
  49. data/lib/sisimai/bite/email/userdefined.rb +7 -7
  50. data/lib/sisimai/bite/email/v5sendmail.rb +21 -22
  51. data/lib/sisimai/bite/email/verizon.rb +8 -8
  52. data/lib/sisimai/bite/email/x1.rb +6 -6
  53. data/lib/sisimai/bite/email/x2.rb +6 -6
  54. data/lib/sisimai/bite/email/x3.rb +6 -6
  55. data/lib/sisimai/bite/email/x4.rb +9 -9
  56. data/lib/sisimai/bite/email/x5.rb +6 -6
  57. data/lib/sisimai/bite/email/yahoo.rb +7 -7
  58. data/lib/sisimai/bite/email/yandex.rb +7 -7
  59. data/lib/sisimai/bite/email/zoho.rb +8 -8
  60. data/lib/sisimai/bite/json.rb +10 -11
  61. data/lib/sisimai/bite/json/amazonses.rb +11 -11
  62. data/lib/sisimai/bite/json/sendgrid.rb +67 -17
  63. data/lib/sisimai/data.rb +19 -21
  64. data/lib/sisimai/data/json.rb +3 -3
  65. data/lib/sisimai/data/yaml.rb +3 -3
  66. data/lib/sisimai/datetime.rb +18 -21
  67. data/lib/sisimai/mail.rb +1 -1
  68. data/lib/sisimai/mail/stdin.rb +2 -2
  69. data/lib/sisimai/mda.rb +4 -4
  70. data/lib/sisimai/message.rb +1 -1
  71. data/lib/sisimai/message/email.rb +32 -35
  72. data/lib/sisimai/message/json.rb +3 -3
  73. data/lib/sisimai/mime.rb +5 -6
  74. data/lib/sisimai/order/email.rb +11 -11
  75. data/lib/sisimai/order/json.rb +3 -3
  76. data/lib/sisimai/reason.rb +2 -2
  77. data/lib/sisimai/reason/userunknown.rb +4 -5
  78. data/lib/sisimai/rfc3464.rb +14 -16
  79. data/lib/sisimai/rfc3834.rb +5 -5
  80. data/lib/sisimai/rfc5322.rb +2 -2
  81. data/lib/sisimai/rhost.rb +6 -5
  82. data/lib/sisimai/rhost/exchangeonline.rb +1 -1
  83. data/lib/sisimai/rhost/godaddy.rb +87 -0
  84. data/lib/sisimai/rhost/googleapps.rb +1 -1
  85. data/lib/sisimai/smtp/error.rb +21 -27
  86. data/lib/sisimai/smtp/status.rb +2 -2
  87. data/lib/sisimai/string.rb +7 -7
  88. data/lib/sisimai/version.rb +1 -1
  89. data/set-of-emails/jsonobj/json-sendgrid-12.json +1 -0
  90. data/set-of-emails/jsonobj/json-sendgrid-13.json +1 -0
  91. data/set-of-emails/jsonobj/json-sendgrid-14.json +1 -0
  92. data/set-of-emails/jsonobj/json-sendgrid-15.json +1 -0
  93. data/set-of-emails/jsonobj/json-sendgrid-16.json +1 -0
  94. data/set-of-emails/jsonobj/json-sendgrid-17.json +1 -0
  95. data/set-of-emails/maildir/bsd/rhost-godaddy-01.eml +83 -0
  96. data/set-of-emails/maildir/bsd/rhost-godaddy-02.eml +69 -0
  97. metadata +12 -6
  98. data/lib/sisimai/ced.rb +0 -48
  99. data/lib/sisimai/msp.rb +0 -39
  100. data/lib/sisimai/mta.rb +0 -39
@@ -1,7 +1,7 @@
1
1
  module Sisimai::Bite::Email
2
+ # Sisimai::Bite::Email::GSuite parses a bounce email which created by G Suite.
3
+ # Methods in the module are called from only Sisimai::Message.
2
4
  module GSuite
3
- # Sisimai::Bite::Email::GSuite parses a bounce email which created by G Suite.
4
- # Methods in the module are called from only Sisimai::Message.
5
5
  class << self
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/GSuite.pm
7
7
  require 'sisimai/bite/email'
@@ -9,19 +9,19 @@ module Sisimai::Bite::Email
9
9
  Re0 = {
10
10
  :from => %r/[@]googlemail[.]com[>]?\z/,
11
11
  :subject => %r/Delivery[ ]Status[ ]Notification/,
12
- }
12
+ }.freeze
13
13
  Re1 = {
14
14
  :begin => %r/\A[*][*][ ].+[ ][*][*]\z/,
15
15
  :error => %r/\AThe[ ]response([ ]from[ ]the[ ]remote[ ]server)?[ ]was:\z/,
16
16
  :html => %r{\AContent-Type:[ ]*text/html;[ ]*charset=['"]?(?:UTF|utf)[-]8['"]?\z},
17
17
  :rfc822 => %r{\AContent-Type:[ ]*(?:message/rfc822|text/rfc822-headers)\z},
18
18
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
19
- }
19
+ }.freeze
20
20
  ErrorMayBe = {
21
21
  :userunknown => %r/because the address couldn't be found/,
22
22
  :notaccept => %r/Null MX/,
23
23
  :networkerror => %r/DNS type .+ lookup of .+ responded with code NXDOMAIN/,
24
- }
24
+ }.freeze
25
25
  Indicators = Sisimai::Bite::Email.INDICATORS
26
26
 
27
27
  def description; return 'G Suite: https://gsuite.google.com'; end
@@ -58,7 +58,7 @@ module Sisimai::Bite::Email
58
58
  endoferror = true # (Integer) Flag for a blank line after error messages
59
59
  anotherset = {} # (Hash) Another error information
60
60
  emptylines = 0 # (Integer) The number of empty lines
61
- connvalues = 0 # (Integer) Flag, 1 if all the value of $connheader have been set
61
+ connvalues = 0 # (Integer) Flag, 1 if all the value of connheader have been set
62
62
  connheader = {
63
63
  'date' => '', # The value of Arrival-Date header
64
64
  'lhost' => '', # The value of Reporting-MTA header
@@ -68,12 +68,10 @@ module Sisimai::Bite::Email
68
68
  hasdivided.each do |e|
69
69
  if readcursor.zero?
70
70
  # Beginning of the bounce message or delivery status part
71
- if e =~ Re1[:begin]
72
- readcursor |= Indicators[:deliverystatus]
73
- end
71
+ readcursor |= Indicators[:deliverystatus] if e =~ Re1[:begin]
74
72
  end
75
73
 
76
- if readcursor & Indicators[:'message-rfc822'] == 0
74
+ if (readcursor & Indicators[:'message-rfc822']).zero?
77
75
  # Beginning of the original message part
78
76
  if e =~ Re1[:rfc822]
79
77
  readcursor |= Indicators[:'message-rfc822']
@@ -92,7 +90,7 @@ module Sisimai::Bite::Email
92
90
 
93
91
  else
94
92
  # Before "message/rfc822"
95
- next if readcursor & Indicators[:deliverystatus] == 0
93
+ next if (readcursor & Indicators[:deliverystatus]).zero?
96
94
 
97
95
  if connvalues == connheader.keys.size
98
96
  # Final-Recipient: rfc822; kijitora@example.de
@@ -137,9 +135,9 @@ module Sisimai::Bite::Email
137
135
  v['diagnosis'] = cv[2]
138
136
  else
139
137
  # Append error messages continued from the previous line
140
- if endoferror && ( v['diagnosis'] && v['diagnosis'].size > 0 )
138
+ if endoferror && (v['diagnosis'] && v['diagnosis'].size > 0)
141
139
  endoferror = true if e.empty?
142
- endoferror = true if e =~ /\A--/
140
+ endoferror = true if e.start_with?('--')
143
141
 
144
142
  next if endoferror
145
143
  next unless e =~ /\A[ ]/
@@ -162,7 +160,7 @@ module Sisimai::Bite::Email
162
160
  elsif cv = e.match(/\A[Aa]rrival-[Dd]ate:[ ]*(.+)\z/)
163
161
  # Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
164
162
  next if connheader['date'].size > 0
165
- connheader['date'] = 1
163
+ connheader['date'] = cv[1]
166
164
  connvalues += 1
167
165
 
168
166
  else
@@ -222,12 +220,12 @@ module Sisimai::Bite::Email
222
220
  if e['diagnosis'] =~ /\A\d+\z/
223
221
  e['diagnosis'] = anotherset['diagnosis']
224
222
  else
225
- # More detailed error message is in "$anotherset"
223
+ # More detailed error message is in "anotherset"
226
224
  as = nil # status
227
225
  ar = nil # replycode
228
226
 
229
227
  if e['status'] == '' || e['status'] =~ /\A[45][.]0[.]0\z/
230
- # Check the value of D.S.N. in $anotherset
228
+ # Check the value of D.S.N. in anotherset
231
229
  as = Sisimai::SMTP::Status.find(anotherset['diagnosis'])
232
230
  if as.size > 0 && as[-3, 3] != '0.0'
233
231
  # The D.S.N. is neither an empty nor *.0.0
@@ -236,7 +234,7 @@ module Sisimai::Bite::Email
236
234
  end
237
235
 
238
236
  if e['replycode'] == '' || e['replycode'] =~ /\A[45]00\z/
239
- # Check the value of SMTP reply code in $anotherset
237
+ # Check the value of SMTP reply code in anotherset
240
238
  ar = Sisimai::SMTP::Reply.find(anotherset['diagnosis'])
241
239
  if ar.size > 0 && ar[-2, 2].to_i != 0
242
240
  # The SMTP reply code is neither an empty nor *00
@@ -244,8 +242,8 @@ module Sisimai::Bite::Email
244
242
  end
245
243
  end
246
244
 
247
- if ( as || ar ) && ( anotherset['diagnosis'].size > e['diagnosis'].size )
248
- # Update the error message in $e->{'diagnosis'}
245
+ if (as || ar) && (anotherset['diagnosis'].size > e['diagnosis'].size)
246
+ # Update the error message in e['diagnosis']
249
247
  e['diagnosis'] = anotherset['diagnosis']
250
248
  end
251
249
  end
@@ -1,8 +1,8 @@
1
1
  module Sisimai::Bite::Email
2
+ # Sisimai::Bite::Email::IMailServer parses a bounce email which created by
3
+ # Ipswitch IMail Server.
4
+ # Methods in the module are called from only Sisimai::Message.
2
5
  module IMailServer
3
- # Sisimai::Bite::Email::IMailServer parses a bounce email which created by
4
- # Ipswitch IMail Server.
5
- # Methods in the module are called from only Sisimai::Message.
6
6
  class << self
7
7
  # Imported from p5-Sisimail/lib/Sisimai/Bite::Email/IMailServer.pm
8
8
  require 'sisimai/bite/email'
@@ -10,13 +10,13 @@ module Sisimai::Bite::Email
10
10
  Re0 = {
11
11
  :'x-mailer' => %r/\A[<]SMTP32 v[\d.]+[>][ ]*\z/,
12
12
  :'subject' => %r/\AUndeliverable Mail[ ]*\z/,
13
- }
13
+ }.freeze
14
14
  Re1 = {
15
15
  :begin => %r/\A\z/, # Blank line
16
16
  :error => %r/Body of message generated response:/,
17
17
  :rfc822 => %r/\AOriginal message follows[.]\z/,
18
18
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
19
- }
19
+ }.freeze
20
20
  ReSMTP = {
21
21
  conn: %r{(?:
22
22
  SMTP[ ]connection[ ]failed,
@@ -27,7 +27,7 @@ module Sisimai::Bite::Email
27
27
  mail: %r|Server response to MAIL FROM:|,
28
28
  rcpt: %r|Additional RCPT TO generated following response:|,
29
29
  data: %r|DATA command generated response:|,
30
- }
30
+ }.freeze
31
31
  ReFailure = {
32
32
  hostunknown: %r/Unknown[ ]host/x,
33
33
  userunknown: %r/\A(?:Unknown[ ]user|Invalid[ ]final[ ]delivery[ ]userid)/x,
@@ -35,7 +35,7 @@ module Sisimai::Bite::Email
35
35
  securityerr: %r/\ARequested[ ]action[ ]not[ ]taken:[ ]virus[ ]detected/x,
36
36
  undefined: %r/\Aundeliverable[ ]to[ ]/x,
37
37
  expired: %r/\ADelivery[ ]failed[ ]\d+[ ]attempts/x,
38
- }
38
+ }.freeze
39
39
  Indicators = Sisimai::Bite::Email.INDICATORS
40
40
 
41
41
  def description; return 'IPSWITCH IMail Server'; end
@@ -80,7 +80,7 @@ module Sisimai::Bite::Email
80
80
  end
81
81
  end
82
82
 
83
- if readcursor & Indicators[:'message-rfc822'] == 0
83
+ if (readcursor & Indicators[:'message-rfc822']).zero?
84
84
  # Beginning of the original message part
85
85
  if e =~ Re1[:rfc822]
86
86
  readcursor |= Indicators[:'message-rfc822']
@@ -145,11 +145,11 @@ module Sisimai::Bite::Email
145
145
 
146
146
  if e['alterrors'] && e['alterrors'].size > 0
147
147
  # Copy alternative error message
148
- if e['diagnosis']
149
- e['diagnosis'] = e['alterrors'] + ' ' + e['diagnosis']
150
- else
151
- e['diagnosis'] = e['alterrors']
152
- end
148
+ e['diagnosis'] = if e['diagnosis']
149
+ e['alterrors'] + ' ' + e['diagnosis']
150
+ else
151
+ e['alterrors']
152
+ end
153
153
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
154
154
  e.delete('alterrors')
155
155
  end
@@ -1,8 +1,8 @@
1
1
  module Sisimai::Bite::Email
2
+ # Sisimai::Bite::Email::InterScanMSS parses a bounce email which created by
3
+ # Trend Micro InterScan Messaging Security Suite. Methods in the module are
4
+ # called from only Sisimai::Message.
2
5
  module InterScanMSS
3
- # Sisimai::Bite::Email::InterScanMSS parses a bounce email which created by
4
- # Trend Micro InterScan Messaging Security Suite. Methods in the module are
5
- # called from only Sisimai::Message.
6
6
  class << self
7
7
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/InterScanMSS.pm
8
8
  require 'sisimai/bite/email'
@@ -17,12 +17,12 @@ module Sisimai::Bite::Email
17
17
  # メール配信に失敗しました
18
18
  '=?iso-2022-jp?B?GyRCJWEhPCVrR1s/LiRLPDpHVCQ3JF4kNyQ/GyhCDQo=?=',
19
19
  ],
20
- }
20
+ }.freeze
21
21
  Re1 = {
22
22
  :begin => %r|\AContent-type: text/plain|,
23
23
  :rfc822 => %r|\AContent-type: message/rfc822|,
24
24
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
25
- }
25
+ }.freeze
26
26
  Indicators = Sisimai::Bite::Email.INDICATORS
27
27
 
28
28
  def description; return 'Trend Micro InterScan Messaging Security Suite'; end
@@ -67,7 +67,7 @@ module Sisimai::Bite::Email
67
67
  end
68
68
  end
69
69
 
70
- if readcursor & Indicators[:'message-rfc822'] == 0
70
+ if (readcursor & Indicators[:'message-rfc822']).zero?
71
71
  # Beginning of the original message part
72
72
  if e =~ Re1[:rfc822]
73
73
  readcursor |= Indicators[:'message-rfc822']
@@ -86,7 +86,7 @@ module Sisimai::Bite::Email
86
86
 
87
87
  else
88
88
  # Before "message/rfc822"
89
- next if readcursor & Indicators[:deliverystatus] == 0
89
+ next if (readcursor & Indicators[:deliverystatus]).zero?
90
90
  next if e.empty?
91
91
 
92
92
  # Sent <<< RCPT TO:<kijitora@example.co.jp>
@@ -1,7 +1,7 @@
1
1
  module Sisimai::Bite::Email
2
+ # Sisimai::Bite::Email::KDDI parses a bounce email which created by au by KDDI.
3
+ # Methods in the module are called from only Sisimai::Message.
2
4
  module KDDI
3
- # Sisimai::Bite::Email::KDDI parses a bounce email which created by au by KDDI.
4
- # Methods in the module are called from only Sisimai::Message.
5
5
  class << self
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/KDDI.pm
7
7
  require 'sisimai/bite/email'
@@ -11,7 +11,7 @@ module Sisimai::Bite::Email
11
11
  :'reply-to' => %r/\Afrom[ \t]+\w+[.]auone[-]net[.]jp[ \t]/,
12
12
  :'received' => %r/\Afrom[ ](?:.+[.])?ezweb[.]ne[.]jp[ ]/,
13
13
  :'message-id' => %r/[@].+[.]ezweb[.]ne[.]jp[>]\z/,
14
- }
14
+ }.freeze
15
15
  Re1 = {
16
16
  :begin => %r/\AYour[ ]mail[ ](?:
17
17
  sent[ ]on:?[ ][A-Z][a-z]{2}[,]
@@ -21,12 +21,12 @@ module Sisimai::Bite::Email
21
21
  :rfc822 => %r|\AContent-Type: message/rfc822\z|,
22
22
  :error => %r/Could not be delivered to:? /,
23
23
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
24
- }
24
+ }.freeze
25
25
  ReFailure = {
26
26
  mailboxfull: %r/As[ ]their[ ]mailbox[ ]is[ ]full/x,
27
27
  norelaying: %r/Due[ ]to[ ]the[ ]following[ ]SMTP[ ]relay[ ]error/x,
28
28
  hostunknown: %r/As[ ]the[ ]remote[ ]domain[ ]doesnt[ ]exist/x,
29
- }
29
+ }.freeze
30
30
  Indicators = Sisimai::Bite::Email.INDICATORS
31
31
 
32
32
  def description; return 'au by KDDI: http://www.au.kddi.com'; end
@@ -75,7 +75,7 @@ module Sisimai::Bite::Email
75
75
  end
76
76
  end
77
77
 
78
- if readcursor & Indicators[:'message-rfc822'] == 0
78
+ if (readcursor & Indicators[:'message-rfc822']).zero?
79
79
  # Beginning of the original message part
80
80
  if e =~ Re1[:rfc822]
81
81
  readcursor |= Indicators[:'message-rfc822']
@@ -94,7 +94,7 @@ module Sisimai::Bite::Email
94
94
 
95
95
  else
96
96
  # Before "message/rfc822"
97
- next if readcursor & Indicators[:deliverystatus] == 0
97
+ next if (readcursor & Indicators[:deliverystatus]).zero?
98
98
  next if e.empty?
99
99
 
100
100
  v = dscontents[-1]
@@ -1,7 +1,7 @@
1
1
  module Sisimai::Bite::Email
2
+ # Sisimai::Bite::Email::MailFoundry parses a bounce email which created by
3
+ # MailFoundry. Methods in the module are called from only Sisimai::Message.
2
4
  module MailFoundry
3
- # Sisimai::Bite::Email::MailFoundry parses a bounce email which created by
4
- # MailFoundry. Methods in the module are called from only Sisimai::Message.
5
5
  class << self
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/MailFoundry.pm
7
7
  require 'sisimai/bite/email'
@@ -9,13 +9,13 @@ module Sisimai::Bite::Email
9
9
  Re0 = {
10
10
  :subject => %r/\AMessage delivery has failed\z/,
11
11
  :received => %r/[(]MAILFOUNDRY[)] id /,
12
- }
12
+ }.freeze
13
13
  Re1 = {
14
14
  :begin => %r/\AThis is a MIME encoded message\z/,
15
15
  :error => %r/\ADelivery failed for the following reason:\z/,
16
16
  :rfc822 => %r|\AContent-Type: message/rfc822\z|,
17
17
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
18
- }
18
+ }.freeze
19
19
  Indicators = Sisimai::Bite::Email.INDICATORS
20
20
 
21
21
  def description; return 'MailFoundry'; end
@@ -57,7 +57,7 @@ module Sisimai::Bite::Email
57
57
  end
58
58
  end
59
59
 
60
- if readcursor & Indicators[:'message-rfc822'] == 0
60
+ if (readcursor & Indicators[:'message-rfc822']).zero?
61
61
  # Beginning of the original message part
62
62
  if e =~ Re1[:rfc822]
63
63
  readcursor |= Indicators[:'message-rfc822']
@@ -76,7 +76,7 @@ module Sisimai::Bite::Email
76
76
 
77
77
  else
78
78
  # Before "message/rfc822"
79
- next if readcursor & Indicators[:deliverystatus] == 0
79
+ next if (readcursor & Indicators[:deliverystatus]).zero?
80
80
  next if e.empty?
81
81
 
82
82
  # Unable to deliver message to: <kijitora@example.org>
@@ -1,22 +1,22 @@
1
1
  module Sisimai::Bite::Email
2
+ # Sisimai::Bite::Email::MailMarshalSMTP parses a bounce email which created
3
+ # by Trustwave Secure Email Gateway: formerly MailMarshal SMTP. Methods in
4
+ # the module are called from only Sisimai::Message.
2
5
  module MailMarshalSMTP
3
- # Sisimai::Bite::Email::MailMarshalSMTP parses a bounce email which created
4
- # by Trustwave Secure Email Gateway: formerly MailMarshal SMTP. Methods in
5
- # the module are called from only Sisimai::Message.
6
6
  class << self
7
7
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/MailMarshalSMTP.pm
8
8
  require 'sisimai/bite/email'
9
9
 
10
10
  Re0 = {
11
11
  :subject => %r/\AUndeliverable Mail: ["]/,
12
- }
12
+ }.freeze
13
13
  Re1 = {
14
14
  :begin => %r/\AYour message:\z/,
15
15
  :rfc822 => nil,
16
16
  :error => %r/\ACould not be delivered because of\z/,
17
17
  :rcpts => %r/\AThe following recipients were affected:/,
18
18
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
19
- }
19
+ }.freeze
20
20
  Indicators = Sisimai::Bite::Email.INDICATORS
21
21
 
22
22
  def description; return 'Trustwave Secure Email Gateway'; end
@@ -52,12 +52,12 @@ module Sisimai::Bite::Email
52
52
  v = nil
53
53
 
54
54
  boundary00 = Sisimai::MIME.boundary(mhead['content-type']) || ''
55
- if boundary00.size > 0
56
- # Convert to regular expression
57
- regularexp = Regexp.new('\A' + Regexp.escape('--' + boundary00 + '--') + '\z')
58
- else
59
- regularexp = %r/\A[ \t]*[+]+[ \t]*\z/
60
- end
55
+ regularexp = if boundary00.size > 0
56
+ # Convert to regular expression
57
+ Regexp.new('\A' + Regexp.escape('--' + boundary00 + '--') + '\z')
58
+ else
59
+ regularexp = %r/\A[ \t]*[+]+[ \t]*\z/
60
+ end
61
61
 
62
62
  hasdivided.each do |e|
63
63
  if readcursor.zero?
@@ -68,7 +68,7 @@ module Sisimai::Bite::Email
68
68
  end
69
69
  end
70
70
 
71
- if readcursor & Indicators[:'message-rfc822'] == 0
71
+ if (readcursor & Indicators[:'message-rfc822']).zero?
72
72
  # Beginning of the original message part
73
73
  if e =~ regularexp
74
74
  readcursor |= Indicators[:'message-rfc822']
@@ -87,7 +87,7 @@ module Sisimai::Bite::Email
87
87
 
88
88
  else
89
89
  # Before "message/rfc822"
90
- next if readcursor & Indicators[:deliverystatus] == 0
90
+ next if (readcursor & Indicators[:deliverystatus]).zero?
91
91
  break if e =~ regularexp
92
92
 
93
93
  # Your message:
@@ -1,7 +1,7 @@
1
1
  module Sisimai::Bite::Email
2
+ # Sisimai::Bite::Email::MailRu parses a bounce email which created by @mail.ru.
3
+ # Methods in the module are called from only Sisimai::Message.
2
4
  module MailRu
3
- # Sisimai::Bite::Email::MailRu parses a bounce email which created by @mail.ru.
4
- # Methods in the module are called from only Sisimai::Message.
5
5
  class << self
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/MailRu.pm
7
7
  # Based on Sisimai::Bite::Email::Exim
@@ -20,16 +20,16 @@ module Sisimai::Bite::Email
20
20
  |error[(]s[)][ ]in[ ]forwarding[ ]or[ ]filtering
21
21
  )
22
22
  }x,
23
- }
23
+ }.freeze
24
24
  Re1 = {
25
25
  :rfc822 => %r/\A------ This is a copy of the message.+headers[.] ------\z/,
26
26
  :begin => %r/\AThis message was created automatically by mail delivery software[.]/,
27
27
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
28
- }
28
+ }.freeze
29
29
  ReCommand = [
30
30
  %r/SMTP error from remote (?:mail server|mailer) after ([A-Za-z]{4})/,
31
31
  %r/SMTP error from remote (?:mail server|mailer) after end of ([A-Za-z]{4})/,
32
- ]
32
+ ].freeze
33
33
  ReFailure = {
34
34
  expired: %r{(?:
35
35
  retry[ ]timeout[ ]exceeded
@@ -57,7 +57,7 @@ module Sisimai::Bite::Email
57
57
  )
58
58
  }x,
59
59
  contenterror: %r/Too[ ]many[ ]["]Received["][ ]headers[ ]/x,
60
- }
60
+ }.freeze
61
61
  Indicators = Sisimai::Bite::Email.INDICATORS
62
62
 
63
63
  def description; return '@mail.ru: https://mail.ru'; end
@@ -101,7 +101,7 @@ module Sisimai::Bite::Email
101
101
  end
102
102
  end
103
103
 
104
- if readcursor & Indicators[:'message-rfc822'] == 0
104
+ if (readcursor & Indicators[:'message-rfc822']).zero?
105
105
  # Beginning of the original message part
106
106
  if e =~ Re1[:rfc822]
107
107
  readcursor |= Indicators[:'message-rfc822']
@@ -121,7 +121,7 @@ module Sisimai::Bite::Email
121
121
 
122
122
  else
123
123
  # Before "message/rfc822"
124
- next if readcursor & Indicators[:deliverystatus] == 0
124
+ next if (readcursor & Indicators[:deliverystatus]).zero?
125
125
  next if e.empty?
126
126
 
127
127
  # Это письмо создано автоматически
@@ -179,7 +179,7 @@ module Sisimai::Bite::Email
179
179
  recipients = rcptinhead.size
180
180
 
181
181
  rcptinhead.each do |e|
182
- # Insert each recipient address into @$dscontents
182
+ # Insert each recipient address into dscontents
183
183
  dscontents[-1]['recipient'] = e
184
184
  next if dscontents.size == recipients
185
185
  dscontents << Sisimai::Bite.DELIVERYSTATUS
@@ -204,7 +204,7 @@ module Sisimai::Bite::Email
204
204
  if e['alterrors'] && e['alterrors'].size > 0
205
205
  # Copy alternative error message
206
206
  e['diagnosis'] ||= e['alterrors']
207
- if e['diagnosis'] =~ /\A[-]+/ || e['diagnosis'] =~ /__\z/
207
+ if e['diagnosis'] =~ /\A[-]+/ || e['diagnosis'].end_with?('__')
208
208
  # Override the value of diagnostic code message
209
209
  e['diagnosis'] = e['alterrors'] if e['alterrors'].size > 0
210
210
  end