mail 2.2.13 → 2.2.14
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mail might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +11 -0
- data/README.rdoc +45 -64
- data/lib/VERSION +1 -1
- data/lib/mail/core_extensions/smtp.rb +2 -2
- data/lib/mail/encodings.rb +10 -12
- data/lib/mail/fields/unstructured_field.rb +3 -1
- data/lib/mail/message.rb +1 -0
- data/lib/mail/network/retriever_methods/imap.rb +1 -1
- data/lib/mail/version_specific/ruby_1_9.rb +31 -12
- metadata +4 -17
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== Mon 3 Jan 2011 12:48:59 UTC Mikel Lindsaar <mikel@rubyx.com>
|
2
|
+
|
3
|
+
* Update field_spec to handle encodings, closes issues 44 and 120 (Luis Lopez)
|
4
|
+
* Version bump to 2.2.14 and gem release
|
5
|
+
|
6
|
+
== Mon 3 Jan 2011 00:09:27 UTC Mikel Lindsaar <mikel@rubyx.com>
|
7
|
+
|
8
|
+
* Use default IANA port on the IMAP retriever_method (Adrian Silva)
|
9
|
+
* Updated README to reflect latest ruby versions we test against (mikel)
|
10
|
+
* Only remove tlsconnect if it exists (mikel)
|
11
|
+
|
1
12
|
== Thu 23 Dec 2010 09:15:58 UTC Mikel Lindsaar <mikel@rubyx.com>
|
2
13
|
|
3
14
|
* Added backport fix for net/smtp bug (Aaron Patterson)
|
data/README.rdoc
CHANGED
@@ -27,16 +27,11 @@ you are doing, you can fiddle with every last bit of your email directly.
|
|
27
27
|
|
28
28
|
Mail is tested and works on the following platforms:
|
29
29
|
|
30
|
-
* jruby-1.
|
31
|
-
* ree-1.8.7-2010.
|
30
|
+
* jruby-1.5.2 [ [x86_64-java] ]
|
31
|
+
* ree-1.8.7-2010.02 [ x86_64 ]
|
32
32
|
* ruby-1.8.6-p399 [ x86_64 ]
|
33
|
-
* ruby-1.8.7-
|
34
|
-
* ruby-1.9.
|
35
|
-
* ruby-1.9.2-head [ x86_64 ] (10 April 2010)
|
36
|
-
|
37
|
-
Mail seems to work fine on JRuby as well, however there is some weird QP
|
38
|
-
problem that only shows up while running the specs, running it directly
|
39
|
-
works fine.... weird. Any jRuby gurus who want to help out, please do.
|
33
|
+
* ruby-1.8.7-p302 [ x86_64 ]
|
34
|
+
* ruby-1.9.2-p0 [ x86_64 ]
|
40
35
|
|
41
36
|
== Discussion
|
42
37
|
|
@@ -63,7 +58,7 @@ field and continue parsing.
|
|
63
58
|
|
64
59
|
This means Mail won't (ever) crunch your data (I think).
|
65
60
|
|
66
|
-
You can also create MIME emails. There are helper methods for making a
|
61
|
+
You can also create MIME emails. There are helper methods for making a
|
67
62
|
multipart/alternate email for text/plain and text/html (the most common pair)
|
68
63
|
and you can manually create any other type of MIME email.
|
69
64
|
|
@@ -73,7 +68,6 @@ Next TODO:
|
|
73
68
|
|
74
69
|
* Improve MIME support for character sets in headers, currently works, mostly, needs
|
75
70
|
refinement.
|
76
|
-
* Add IMAP wrapper
|
77
71
|
|
78
72
|
== Testing Policy
|
79
73
|
|
@@ -94,23 +88,10 @@ Also, all private or protected methods to be declared as such - though this is s
|
|
94
88
|
|
95
89
|
== Installation
|
96
90
|
|
97
|
-
Installation is fairly simple, I host mail on
|
91
|
+
Installation is fairly simple, I host mail on rubygems, so you can just do:
|
98
92
|
|
99
93
|
# gem install mail
|
100
94
|
|
101
|
-
if you are on gemcutter, if you aren't, you can by doing:
|
102
|
-
|
103
|
-
# gem install gemcutter
|
104
|
-
# gem tumble
|
105
|
-
# gem install mail
|
106
|
-
|
107
|
-
Warning though, the above will change your first gem repository to gemcutter, this
|
108
|
-
may or may not be a problem for you.
|
109
|
-
|
110
|
-
If you want to install mail manually, you can download the gem from github and do:
|
111
|
-
|
112
|
-
# gem install mail-2.2.0.gem
|
113
|
-
|
114
95
|
== Encodings
|
115
96
|
|
116
97
|
If you didn't know, handling encodings in Emails is not as straight forward as you
|
@@ -122,26 +103,26 @@ I have tried to simplify it some:
|
|
122
103
|
return the object as a complete string ready to send in the mail system, that is,
|
123
104
|
it will include the header field and value and CRLF at the end and wrapped as
|
124
105
|
needed.
|
125
|
-
|
106
|
+
|
126
107
|
2. All objects that can render into an email, have a :decoded method. Decoded will
|
127
108
|
return the object's "value" only as a string. This means it will not include
|
128
109
|
the header fields (like 'To:' or 'Subject:').
|
129
|
-
|
110
|
+
|
130
111
|
3. By default, calling :to_s on a container object will call it's encoded method, while
|
131
112
|
:to_s on a field object will call it's decoded method. So calling :to_s on a Mail
|
132
113
|
object will return the mail, all encoded ready to send, while calling :to_s on the
|
133
114
|
From field or the body will return the decoded value of the object. The header object
|
134
115
|
of Mail is considered a container. If you are in doubt, call :encoded, or :decoded
|
135
116
|
explicitly, this is safer if you are not sure.
|
136
|
-
|
117
|
+
|
137
118
|
4. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will
|
138
119
|
provide decoded parameter values when you call the parameter names as methods against
|
139
120
|
the object.
|
140
|
-
|
121
|
+
|
141
122
|
5. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will
|
142
|
-
provide encoded parameter values when you call the parameter names through the
|
123
|
+
provide encoded parameter values when you call the parameter names through the
|
143
124
|
object.parameters['<parameter_name>'] method call.
|
144
|
-
|
125
|
+
|
145
126
|
== Contributing
|
146
127
|
|
147
128
|
Please do! Contributing is easy in Mail:
|
@@ -163,7 +144,7 @@ So, you should be able to just "require 'mail'" to get started.
|
|
163
144
|
=== Making an email
|
164
145
|
|
165
146
|
require 'mail'
|
166
|
-
|
147
|
+
|
167
148
|
mail = Mail.new do
|
168
149
|
from 'mikel@test.lindsaar.net'
|
169
150
|
to 'you@test.lindsaar.net'
|
@@ -176,7 +157,7 @@ So, you should be able to just "require 'mail'" to get started.
|
|
176
157
|
=== Making an email, have it your way:
|
177
158
|
|
178
159
|
require 'mail'
|
179
|
-
|
160
|
+
|
180
161
|
mail = Mail.new do
|
181
162
|
body File.read('body.txt')
|
182
163
|
end
|
@@ -184,35 +165,35 @@ So, you should be able to just "require 'mail'" to get started.
|
|
184
165
|
mail['from'] = 'mikel@test.lindsaar.net'
|
185
166
|
mail[:to] = 'you@test.lindsaar.net'
|
186
167
|
mail.subject = 'This is a test email'
|
187
|
-
|
168
|
+
|
188
169
|
mail.to_s #=> "From: mikel@test.lindsaar.net\r\nTo: you@...
|
189
170
|
|
190
171
|
=== Don't Worry About Message IDs:
|
191
172
|
|
192
173
|
require 'mail'
|
193
|
-
|
174
|
+
|
194
175
|
mail = Mail.new do
|
195
176
|
to 'you@test.lindsaar.net'
|
196
177
|
body 'Some simple body'
|
197
178
|
end
|
198
179
|
|
199
180
|
mail.to_s =~ /Message\-ID: <[\d\w_]+@.+.mail/ #=> 27
|
200
|
-
|
181
|
+
|
201
182
|
Mail will automatically add a Message-ID field if it is missing and
|
202
183
|
give it a unique, random Message-ID along the lines of:
|
203
184
|
|
204
185
|
<4a7ff76d7016_13a81ab802e1@local.fqdn.mail>
|
205
|
-
|
186
|
+
|
206
187
|
=== Or do worry about Message-IDs:
|
207
188
|
|
208
189
|
require 'mail'
|
209
|
-
|
190
|
+
|
210
191
|
mail = Mail.new do
|
211
192
|
to 'you@test.lindsaar.net'
|
212
193
|
message_id '<ThisIsMyMessageId@some.domain.com>'
|
213
194
|
body 'Some simple body'
|
214
195
|
end
|
215
|
-
|
196
|
+
|
216
197
|
mail.to_s =~ /Message\-ID: <ThisIsMyMessageId@some.domain.com>/ #=> 27
|
217
198
|
|
218
199
|
Mail will take the message_id you assign to it trusting that you know
|
@@ -220,7 +201,7 @@ what you are doing.
|
|
220
201
|
|
221
202
|
=== Sending an email:
|
222
203
|
|
223
|
-
Mail defaults to sending via SMTP to local host port 25. If you have a
|
204
|
+
Mail defaults to sending via SMTP to local host port 25. If you have a
|
224
205
|
sendmail or postfix daemon running on on this port, sending email is as
|
225
206
|
easy as:
|
226
207
|
|
@@ -233,7 +214,7 @@ easy as:
|
|
233
214
|
end
|
234
215
|
|
235
216
|
or
|
236
|
-
|
217
|
+
|
237
218
|
mail = Mail.new do
|
238
219
|
from 'me@test.lindsaar.net'
|
239
220
|
to 'you@test.lindsaar.net'
|
@@ -241,7 +222,7 @@ or
|
|
241
222
|
body File.read('body.txt')
|
242
223
|
add_file {:filename => 'somefile.png', :content => File.read('/somefile.png')}
|
243
224
|
end
|
244
|
-
|
225
|
+
|
245
226
|
mail.deliver!
|
246
227
|
|
247
228
|
Sending via sendmail can be done like so:
|
@@ -253,9 +234,9 @@ Sending via sendmail can be done like so:
|
|
253
234
|
body File.read('body.txt')
|
254
235
|
add_file {:filename => 'somefile.png', :content => File.read('/somefile.png')}
|
255
236
|
end
|
256
|
-
|
237
|
+
|
257
238
|
mail.delivery_method :sendmail
|
258
|
-
|
239
|
+
|
259
240
|
mail.deliver
|
260
241
|
|
261
242
|
{Learn more about SMTP Delivery}[link:classes/Mail/SMTP.html]
|
@@ -318,9 +299,9 @@ Or even all emails:
|
|
318
299
|
=== Reading an Email
|
319
300
|
|
320
301
|
require 'mail'
|
321
|
-
|
302
|
+
|
322
303
|
mail = Mail.read('/path/to/message.eml')
|
323
|
-
|
304
|
+
|
324
305
|
mail.envelope.from #=> 'mikel@test.lindsaar.net'
|
325
306
|
mail.from.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
|
326
307
|
mail.sender.address #=> 'mikel@test.lindsaar.net'
|
@@ -336,9 +317,9 @@ Many more methods available.
|
|
336
317
|
=== Reading a Multipart Email
|
337
318
|
|
338
319
|
require 'mail'
|
339
|
-
|
320
|
+
|
340
321
|
mail = Mail.read('multipart_email')
|
341
|
-
|
322
|
+
|
342
323
|
mail.multipart? #=> true
|
343
324
|
mail.parts.length #=> 2
|
344
325
|
mail.preamble #=> "Text before the first part"
|
@@ -356,7 +337,7 @@ content type and has a boundary defined.
|
|
356
337
|
|
357
338
|
=== Writing and sending a multipart/alternative (html and text) email
|
358
339
|
|
359
|
-
Mail makes some basic assumptions and makes doing the common thing as
|
340
|
+
Mail makes some basic assumptions and makes doing the common thing as
|
360
341
|
simple as possible.... (asking a lot from a mail library)
|
361
342
|
|
362
343
|
require 'mail'
|
@@ -373,7 +354,7 @@ simple as possible.... (asking a lot from a mail library)
|
|
373
354
|
body '<h1>This is HTML</h1>'
|
374
355
|
end
|
375
356
|
end
|
376
|
-
|
357
|
+
|
377
358
|
Mail then delivers the email at the end of the block and returns the
|
378
359
|
resulting Mail::Message object, which you can then inspect if you
|
379
360
|
so desire...
|
@@ -409,7 +390,7 @@ so desire...
|
|
409
390
|
<h1>This is HTML</h1>
|
410
391
|
----==_mimepart_4a914f0c911be_6f0f1ab8026659--
|
411
392
|
|
412
|
-
Mail inserts the content transfer encoding, the mime version,
|
393
|
+
Mail inserts the content transfer encoding, the mime version,
|
413
394
|
the content-id's and handles the content-type and boundary.
|
414
395
|
|
415
396
|
Mail assumes that if your text in the body is only us-ascii, that your
|
@@ -423,7 +404,7 @@ can just do it declaratively. However, you need to add Mail::Parts to
|
|
423
404
|
an email, not Mail::Messages.
|
424
405
|
|
425
406
|
require 'mail'
|
426
|
-
|
407
|
+
|
427
408
|
mail = Mail.new do
|
428
409
|
to 'nicolas@test.lindsaar.net.au'
|
429
410
|
from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
|
@@ -433,12 +414,12 @@ an email, not Mail::Messages.
|
|
433
414
|
text_part = Mail::Part.new do
|
434
415
|
body 'This is plain text'
|
435
416
|
end
|
436
|
-
|
417
|
+
|
437
418
|
html_part = Mail::Part.new do
|
438
419
|
content_type 'text/html; charset=UTF-8'
|
439
420
|
body '<h1>This is HTML</h1>'
|
440
421
|
end
|
441
|
-
|
422
|
+
|
442
423
|
mail.text_part = text_part
|
443
424
|
mail.html_part = html_part
|
444
425
|
|
@@ -447,14 +428,14 @@ Results in the same email as done using the block form
|
|
447
428
|
=== Getting error reports from an email:
|
448
429
|
|
449
430
|
require 'mail'
|
450
|
-
|
431
|
+
|
451
432
|
@mail = Mail.read('/path/to/bounce_message.eml')
|
452
|
-
|
433
|
+
|
453
434
|
@mail.bounced? #=> true
|
454
435
|
@mail.final_recipient #=> rfc822;mikel@dont.exist.com
|
455
436
|
@mail.action #=> failed
|
456
437
|
@mail.error_status #=> 5.5.0
|
457
|
-
@mail.diagnostic_code #=> smtp;550 Requested action not taken: mailbox unavailable
|
438
|
+
@mail.diagnostic_code #=> smtp;550 Requested action not taken: mailbox unavailable
|
458
439
|
@mail.retryable? #=> false
|
459
440
|
|
460
441
|
=== Attaching and Detaching Files
|
@@ -463,7 +444,7 @@ Results in the same email as done using the block form
|
|
463
444
|
|
464
445
|
You can just read the file off an absolute path, Mail will try
|
465
446
|
to guess the mime_type and will encode the file in Base64 for you.
|
466
|
-
|
447
|
+
|
467
448
|
@mail = Mail.new
|
468
449
|
@mail.add_file("/path/to/file.jpg")
|
469
450
|
@mail.parts.first.attachment? #=> true
|
@@ -474,7 +455,7 @@ to guess the mime_type and will encode the file in Base64 for you.
|
|
474
455
|
|
475
456
|
Or You can pass in file_data and give it a filename, again, mail
|
476
457
|
will try and guess the mime_type for you.
|
477
|
-
|
458
|
+
|
478
459
|
@mail = Mail.new
|
479
460
|
@mail.attachments['myfile.pdf'] = File.read('path/to/myfile.pdf')
|
480
461
|
@mail.parts.first.attachment? #=> true
|
@@ -507,7 +488,7 @@ Of course... Mail will round trip an attachment as well
|
|
507
488
|
end
|
508
489
|
|
509
490
|
@round_tripped_mail = Mail.new(@mail.encoded)
|
510
|
-
|
491
|
+
|
511
492
|
@round_tripped_mail.attachments.length #=> 1
|
512
493
|
@round_tripped_mail.attachments.first.filename #=> 'myfile.pdf'
|
513
494
|
|
@@ -540,9 +521,9 @@ sending emails, the TestMailer can do this for you.
|
|
540
521
|
|
541
522
|
== Excerpts from TREC Spam Corpus 2005
|
542
523
|
|
543
|
-
The spec fixture files in spec/fixtures/emails/from_trec_2005 are from the
|
524
|
+
The spec fixture files in spec/fixtures/emails/from_trec_2005 are from the
|
544
525
|
2005 TREC Public Spam Corpus. They remain copyrighted under the terms of
|
545
|
-
that project and license agreement. They are used in this project to verify
|
526
|
+
that project and license agreement. They are used in this project to verify
|
546
527
|
and describe the development of this email parser implementation.
|
547
528
|
|
548
529
|
http://plg.uwaterloo.ca/~gvcormac/treccorpus/
|
@@ -553,14 +534,14 @@ They are used as allowed by 'Permitted Uses, Clause 3':
|
|
553
534
|
or published in a scientific or technical context, solely for
|
554
535
|
the purpose of describing the research and development and
|
555
536
|
related issues."
|
556
|
-
|
537
|
+
|
557
538
|
-- http://plg.uwaterloo.ca/~gvcormac/treccorpus/
|
558
539
|
|
559
540
|
== License:
|
560
541
|
|
561
542
|
(The MIT License)
|
562
543
|
|
563
|
-
Copyright (c) 2009
|
544
|
+
Copyright (c) 2009, 2010, 2011
|
564
545
|
|
565
546
|
Permission is hereby granted, free of charge, to any person obtaining
|
566
547
|
a copy of this software and associated documentation files (the
|
data/lib/VERSION
CHANGED
@@ -3,8 +3,8 @@ module Net
|
|
3
3
|
# This is a backport of r30294 from ruby trunk because of a bug in net/smtp.
|
4
4
|
# http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30294
|
5
5
|
#
|
6
|
-
# Fixed in what will be Ruby 1.9.3
|
7
|
-
remove_method :tlsconnect
|
6
|
+
# Fixed in what will be Ruby 1.9.3 - tlsconnect also does not exist in some early versions of ruby
|
7
|
+
remove_method :tlsconnect if defined?(Net::SMTP.new.tlsconnect)
|
8
8
|
|
9
9
|
def tlsconnect(s)
|
10
10
|
verified = false
|
data/lib/mail/encodings.rb
CHANGED
@@ -120,7 +120,7 @@ module Mail
|
|
120
120
|
|
121
121
|
# Split on white-space boundaries with capture, so we capture the white-space as well
|
122
122
|
str.split(/([ \t])/).map do |text|
|
123
|
-
if text.index('=?')
|
123
|
+
if text.index('=?') .nil?
|
124
124
|
text
|
125
125
|
else
|
126
126
|
# Join QP encoded-words that are adjacent to avoid decoding partial chars
|
@@ -128,17 +128,11 @@ module Mail
|
|
128
128
|
|
129
129
|
# Separate encoded-words with a space, so we can treat them one by one
|
130
130
|
text.gsub!(/\?\=\=\?/, '?= =?')
|
131
|
-
|
132
131
|
text.split(/ /).map do |word|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
when text.to_str =~ /=\?.+\?[Qq]\?/m
|
137
|
-
q_value_decode(word)
|
138
|
-
else
|
139
|
-
word.to_str
|
132
|
+
word.to_str.
|
133
|
+
gsub(/=\?.+\?[Bb]\?.+\?=/m) {|substr| b_value_decode(substr)}.
|
134
|
+
gsub(/=\?.+\?[Qq]\?.+\?=/m) {|substr| q_value_decode(substr)}
|
140
135
|
end
|
141
|
-
end
|
142
136
|
end
|
143
137
|
end.join("")
|
144
138
|
end
|
@@ -153,8 +147,12 @@ module Mail
|
|
153
147
|
output
|
154
148
|
elsif original_encoding && to_encoding
|
155
149
|
begin
|
156
|
-
|
157
|
-
|
150
|
+
if RUBY_VERSION >= '1.9'
|
151
|
+
output.encode(to_encoding)
|
152
|
+
else
|
153
|
+
require 'iconv'
|
154
|
+
Iconv.iconv(to_encoding, original_encoding, output).first
|
155
|
+
end
|
158
156
|
rescue Iconv::IllegalSequence, Iconv::InvalidEncoding, Errno::EINVAL
|
159
157
|
# the 'from' parameter specifies a charset other than what the text
|
160
158
|
# actually is...not much we can do in this case but just return the
|
@@ -71,7 +71,9 @@ module Mail
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def do_decode
|
74
|
-
value.blank? ? nil : Encodings.decode_encode(value, :decode)
|
74
|
+
result = value.blank? ? nil : Encodings.decode_encode(value, :decode)
|
75
|
+
result.encode!(value.encoding || "UTF-8") if RUBY_VERSION >= '1.9' && !result.blank?
|
76
|
+
result
|
75
77
|
end
|
76
78
|
|
77
79
|
# 2.2.3. Long Header Fields
|
data/lib/mail/message.rb
CHANGED
@@ -14,7 +14,7 @@ module Mail
|
|
14
14
|
str = escape_paren( str )
|
15
15
|
'(' + str + ')'
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def Ruby19.escape_bracket( str )
|
19
19
|
re = /(?<!\\)([\<\>])/ # Only match unescaped brackets
|
20
20
|
str.gsub(re) { |s| '\\' + s }
|
@@ -29,34 +29,34 @@ module Mail
|
|
29
29
|
def Ruby19.decode_base64(str)
|
30
30
|
str.unpack( 'm' ).first.force_encoding(Encoding::BINARY)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def Ruby19.encode_base64(str)
|
34
34
|
[str].pack( 'm' )
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def Ruby19.has_constant?(klass, string)
|
38
38
|
klass.constants.include?( string.to_sym )
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def Ruby19.get_constant(klass, string)
|
42
42
|
klass.const_get( string.to_sym )
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def Ruby19.b_value_encode(str, encoding = nil)
|
46
46
|
encoding = str.encoding.to_s
|
47
47
|
[Ruby19.encode_base64(str), encoding]
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def Ruby19.b_value_decode(str)
|
51
51
|
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
|
52
52
|
if match
|
53
53
|
encoding = match[1]
|
54
|
-
str = Ruby19.decode_base64(match[2]
|
55
|
-
str.force_encoding(encoding)
|
54
|
+
str = Ruby19.decode_base64(match[2])
|
55
|
+
str.force_encoding(fix_encoding(encoding))
|
56
56
|
end
|
57
|
-
str
|
57
|
+
str.encode("utf-8", :invalid => :replace, :replace => "")
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def Ruby19.q_value_encode(str, encoding = nil)
|
61
61
|
encoding = str.encoding.to_s
|
62
62
|
[Encodings::QuotedPrintable.encode(str), encoding]
|
@@ -67,9 +67,9 @@ module Mail
|
|
67
67
|
if match
|
68
68
|
encoding = match[1]
|
69
69
|
str = Encodings::QuotedPrintable.decode(match[2])
|
70
|
-
str.force_encoding(encoding)
|
70
|
+
str.force_encoding(fix_encoding(encoding))
|
71
71
|
end
|
72
|
-
str
|
72
|
+
str.encode("utf-8", :invalid => :replace, :replace => "")
|
73
73
|
end
|
74
74
|
|
75
75
|
def Ruby19.param_decode(str, encoding)
|
@@ -83,5 +83,24 @@ module Mail
|
|
83
83
|
language = Configuration.instance.param_encode_language
|
84
84
|
"#{encoding}'#{language}'#{URI.escape(str)}"
|
85
85
|
end
|
86
|
+
|
87
|
+
# mails somtimes includes invalid encodings like iso885915 or utf8 so we transform them to iso885915 or utf8
|
88
|
+
# TODO: add this as a test somewhere
|
89
|
+
# Encoding.list.map{|e| [e.to_s.upcase==fix_encoding(e.to_s.downcase.gsub("-", "")), e.to_s] }.select {|a,b| !b}
|
90
|
+
# Encoding.list.map{|e| [e.to_s==fix_encoding(e.to_s), e.to_s] }.select {|a,b| !b}
|
91
|
+
def Ruby19.fix_encoding(encoding)
|
92
|
+
case encoding
|
93
|
+
# ISO-8859-15, ISO-2022-JP and alike
|
94
|
+
when /iso-?(\d{4})-?(\w{1,2})/i then return "ISO-#{$1}-#{$2}"
|
95
|
+
# "ISO-2022-JP-KDDI" and alike
|
96
|
+
when /iso-?(\d{4})-?(\w{1,2})-?(\w*)/i then return "ISO-#{$1}-#{$2}-#{$3}"
|
97
|
+
# utf-8 and alike
|
98
|
+
when /utf-?(.*)/i then return "UTF-#{$1}"
|
99
|
+
# Windows-1252 and alike
|
100
|
+
when /Windows-?(.*)/i then return "Windows-#{$1}"
|
101
|
+
#more aliases to be added if needed
|
102
|
+
else return encoding
|
103
|
+
end
|
104
|
+
end
|
86
105
|
end
|
87
106
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 2
|
8
7
|
- 2
|
9
|
-
-
|
10
|
-
version: 2.2.
|
8
|
+
- 14
|
9
|
+
version: 2.2.14
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Mikel Lindsaar
|
@@ -15,18 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2011-01-05 00:00:00 +11:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: activesupport
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 15
|
30
27
|
segments:
|
31
28
|
- 2
|
32
29
|
- 3
|
@@ -38,11 +35,9 @@ dependencies:
|
|
38
35
|
name: mime-types
|
39
36
|
prerelease: false
|
40
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
39
|
- - ~>
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 47
|
46
41
|
segments:
|
47
42
|
- 1
|
48
43
|
- 16
|
@@ -53,11 +48,9 @@ dependencies:
|
|
53
48
|
name: treetop
|
54
49
|
prerelease: false
|
55
50
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
51
|
requirements:
|
58
52
|
- - ~>
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 23
|
61
54
|
segments:
|
62
55
|
- 1
|
63
56
|
- 4
|
@@ -69,11 +62,9 @@ dependencies:
|
|
69
62
|
name: i18n
|
70
63
|
prerelease: false
|
71
64
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
65
|
requirements:
|
74
66
|
- - ">="
|
75
67
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 15
|
77
68
|
segments:
|
78
69
|
- 0
|
79
70
|
- 4
|
@@ -225,27 +216,23 @@ rdoc_options: []
|
|
225
216
|
require_paths:
|
226
217
|
- lib
|
227
218
|
required_ruby_version: !ruby/object:Gem::Requirement
|
228
|
-
none: false
|
229
219
|
requirements:
|
230
220
|
- - ">="
|
231
221
|
- !ruby/object:Gem::Version
|
232
|
-
hash: 3
|
233
222
|
segments:
|
234
223
|
- 0
|
235
224
|
version: "0"
|
236
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
|
-
none: false
|
238
226
|
requirements:
|
239
227
|
- - ">="
|
240
228
|
- !ruby/object:Gem::Version
|
241
|
-
hash: 3
|
242
229
|
segments:
|
243
230
|
- 0
|
244
231
|
version: "0"
|
245
232
|
requirements: []
|
246
233
|
|
247
234
|
rubyforge_project:
|
248
|
-
rubygems_version: 1.3.
|
235
|
+
rubygems_version: 1.3.6
|
249
236
|
signing_key:
|
250
237
|
specification_version: 3
|
251
238
|
summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
|