actionmailer 2.0.5 → 2.1.0

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

Potentially problematic release.


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

Files changed (73) hide show
  1. data/CHANGELOG +2 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README +14 -10
  4. data/Rakefile +3 -4
  5. data/lib/action_mailer.rb +1 -1
  6. data/lib/action_mailer/adv_attr_accessor.rb +1 -1
  7. data/lib/action_mailer/base.rb +140 -100
  8. data/lib/action_mailer/helpers.rb +7 -7
  9. data/lib/action_mailer/part.rb +2 -2
  10. data/lib/action_mailer/quoting.rb +3 -1
  11. data/lib/action_mailer/test_case.rb +14 -22
  12. data/lib/action_mailer/vendor.rb +2 -2
  13. data/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb +0 -0
  14. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail.rb +1 -0
  15. data/lib/action_mailer/vendor/tmail-1.2.3/tmail/address.rb +426 -0
  16. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/attachments.rb +2 -3
  17. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/base64.rb +4 -10
  18. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/compat.rb +8 -6
  19. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/config.rb +2 -6
  20. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/core_extensions.rb +14 -18
  21. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/encode.rb +77 -19
  22. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/header.rb +7 -10
  23. data/lib/action_mailer/vendor/tmail-1.2.3/tmail/index.rb +9 -0
  24. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/interface.rb +20 -13
  25. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/loader.rb +2 -0
  26. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/mail.rb +97 -26
  27. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/mailbox.rb +70 -10
  28. data/lib/action_mailer/vendor/tmail-1.2.3/tmail/main.rb +6 -0
  29. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/mbox.rb +2 -0
  30. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/net.rb +16 -15
  31. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/obsolete.rb +7 -12
  32. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/parser.rb +1 -0
  33. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/port.rb +0 -0
  34. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/quoting.rb +0 -0
  35. data/lib/action_mailer/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
  36. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/scanner.rb +3 -1
  37. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/scanner_r.rb +15 -15
  38. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/stringio.rb +1 -0
  39. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/utils.rb +89 -32
  40. data/lib/action_mailer/vendor/{tmail-1.2.1 → tmail-1.2.3}/tmail/version.rb +4 -3
  41. data/lib/action_mailer/version.rb +2 -2
  42. data/test/delivery_method_test.rb +1 -1
  43. data/test/mail_helper_test.rb +1 -1
  44. data/test/mail_render_test.rb +1 -1
  45. data/test/mail_service_test.rb +48 -9
  46. data/test/quoting_test.rb +19 -32
  47. data/test/test_helper_test.rb +3 -9
  48. data/test/tmail_test.rb +1 -1
  49. data/test/url_test.rb +2 -2
  50. metadata +33 -53
  51. data/lib/action_mailer/vendor/tmail-1.2.1/tmail/Makefile +0 -19
  52. data/lib/action_mailer/vendor/tmail-1.2.1/tmail/address.rb +0 -245
  53. data/lib/action_mailer/vendor/tmail-1.2.1/tmail/facade.rb +0 -552
  54. data/lib/action_mailer/vendor/tmail-1.2.1/tmail/info.rb +0 -35
  55. data/lib/action_mailer/vendor/tmail-1.2.1/tmail/parser.y +0 -381
  56. data/lib/action_mailer/vendor/tmail-1.2.1/tmail/tmail.rb +0 -1
  57. data/test/fixtures/first_mailer/share.rhtml +0 -0
  58. data/test/fixtures/helper_mailer/use_example_helper.rhtml +0 -0
  59. data/test/fixtures/helper_mailer/use_helper.rhtml +0 -0
  60. data/test/fixtures/helper_mailer/use_helper_method.rhtml +0 -0
  61. data/test/fixtures/helper_mailer/use_mail_helper.rhtml +0 -0
  62. data/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml +0 -0
  63. data/test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml +0 -0
  64. data/test/fixtures/raw_base64_decoded_string +0 -0
  65. data/test/fixtures/raw_base64_encoded_string +0 -1
  66. data/test/fixtures/second_mailer/share.rhtml +0 -0
  67. data/test/fixtures/templates/signed_up.rhtml +0 -0
  68. data/test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml +0 -0
  69. data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.rhtml +0 -0
  70. data/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.rhtml +0 -0
  71. data/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml +0 -0
  72. data/test/fixtures/test_mailer/signed_up.rhtml +0 -0
  73. data/test/fixtures/test_mailer/signed_up_with_url.rhtml +0 -0
@@ -1,552 +0,0 @@
1
- #
2
- # facade.rb
3
- #
4
- #--
5
- # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining
8
- # a copy of this software and associated documentation files (the
9
- # "Software"), to deal in the Software without restriction, including
10
- # without limitation the rights to use, copy, modify, merge, publish,
11
- # distribute, sublicense, and/or sell copies of the Software, and to
12
- # permit persons to whom the Software is furnished to do so, subject to
13
- # the following conditions:
14
- #
15
- # The above copyright notice and this permission notice shall be
16
- # included in all copies or substantial portions of the Software.
17
- #
18
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- #
26
- # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
27
- # with permission of Minero Aoki.
28
- #++
29
-
30
- require 'tmail/utils'
31
-
32
-
33
- module TMail
34
-
35
- class Mail
36
-
37
- def header_string( name, default = nil )
38
- h = @header[name.downcase] or return default
39
- h.to_s
40
- end
41
-
42
- ###
43
- ### attributes
44
- ###
45
-
46
- include TextUtils
47
-
48
- def set_string_array_attr( key, strs )
49
- strs.flatten!
50
- if strs.empty?
51
- @header.delete key.downcase
52
- else
53
- store key, strs.join(', ')
54
- end
55
- strs
56
- end
57
- private :set_string_array_attr
58
-
59
- def set_string_attr( key, str )
60
- if str
61
- store key, str
62
- else
63
- @header.delete key.downcase
64
- end
65
- str
66
- end
67
- private :set_string_attr
68
-
69
- def set_addrfield( name, arg )
70
- if arg
71
- h = HeaderField.internal_new(name, @config)
72
- h.addrs.replace [arg].flatten
73
- @header[name] = h
74
- else
75
- @header.delete name
76
- end
77
- arg
78
- end
79
- private :set_addrfield
80
-
81
- def addrs2specs( addrs )
82
- return nil unless addrs
83
- list = addrs.map {|addr|
84
- if addr.address_group?
85
- then addr.map {|a| a.spec }
86
- else addr.spec
87
- end
88
- }.flatten
89
- return nil if list.empty?
90
- list
91
- end
92
- private :addrs2specs
93
-
94
-
95
- #
96
- # date time
97
- #
98
-
99
- def date( default = nil )
100
- if h = @header['date']
101
- h.date
102
- else
103
- default
104
- end
105
- end
106
-
107
- def date=( time )
108
- if time
109
- store 'Date', time2str(time)
110
- else
111
- @header.delete 'date'
112
- end
113
- time
114
- end
115
-
116
- def strftime( fmt, default = nil )
117
- if t = date
118
- t.strftime(fmt)
119
- else
120
- default
121
- end
122
- end
123
-
124
-
125
- #
126
- # destination
127
- #
128
-
129
- def to_addrs( default = nil )
130
- if h = @header['to']
131
- h.addrs
132
- else
133
- default
134
- end
135
- end
136
-
137
- def cc_addrs( default = nil )
138
- if h = @header['cc']
139
- h.addrs
140
- else
141
- default
142
- end
143
- end
144
-
145
- def bcc_addrs( default = nil )
146
- if h = @header['bcc']
147
- h.addrs
148
- else
149
- default
150
- end
151
- end
152
-
153
- def to_addrs=( arg )
154
- set_addrfield 'to', arg
155
- end
156
-
157
- def cc_addrs=( arg )
158
- set_addrfield 'cc', arg
159
- end
160
-
161
- def bcc_addrs=( arg )
162
- set_addrfield 'bcc', arg
163
- end
164
-
165
- def to( default = nil )
166
- addrs2specs(to_addrs(nil)) || default
167
- end
168
-
169
- def cc( default = nil )
170
- addrs2specs(cc_addrs(nil)) || default
171
- end
172
-
173
- def bcc( default = nil )
174
- addrs2specs(bcc_addrs(nil)) || default
175
- end
176
-
177
- def to=( *strs )
178
- set_string_array_attr 'To', strs
179
- end
180
-
181
- def cc=( *strs )
182
- set_string_array_attr 'Cc', strs
183
- end
184
-
185
- def bcc=( *strs )
186
- set_string_array_attr 'Bcc', strs
187
- end
188
-
189
-
190
- #
191
- # originator
192
- #
193
-
194
- def from_addrs( default = nil )
195
- if h = @header['from']
196
- h.addrs
197
- else
198
- default
199
- end
200
- end
201
-
202
- def from_addrs=( arg )
203
- set_addrfield 'from', arg
204
- end
205
-
206
- def from( default = nil )
207
- addrs2specs(from_addrs(nil)) || default
208
- end
209
-
210
- def from=( *strs )
211
- set_string_array_attr 'From', strs
212
- end
213
-
214
- def friendly_from( default = nil )
215
- h = @header['from']
216
- a, = h.addrs
217
- return default unless a
218
- return a.phrase if a.phrase
219
- return h.comments.join(' ') unless h.comments.empty?
220
- a.spec
221
- end
222
-
223
-
224
- def reply_to_addrs( default = nil )
225
- if h = @header['reply-to']
226
- h.addrs
227
- else
228
- default
229
- end
230
- end
231
-
232
- def reply_to_addrs=( arg )
233
- set_addrfield 'reply-to', arg
234
- end
235
-
236
- def reply_to( default = nil )
237
- addrs2specs(reply_to_addrs(nil)) || default
238
- end
239
-
240
- def reply_to=( *strs )
241
- set_string_array_attr 'Reply-To', strs
242
- end
243
-
244
-
245
- def sender_addr( default = nil )
246
- f = @header['sender'] or return default
247
- f.addr or return default
248
- end
249
-
250
- def sender_addr=( addr )
251
- if addr
252
- h = HeaderField.internal_new('sender', @config)
253
- h.addr = addr
254
- @header['sender'] = h
255
- else
256
- @header.delete 'sender'
257
- end
258
- addr
259
- end
260
-
261
- def sender( default )
262
- f = @header['sender'] or return default
263
- a = f.addr or return default
264
- a.spec
265
- end
266
-
267
- def sender=( str )
268
- set_string_attr 'Sender', str
269
- end
270
-
271
-
272
- #
273
- # subject
274
- #
275
-
276
- def subject( default = nil )
277
- if h = @header['subject']
278
- h.body
279
- else
280
- default
281
- end
282
- end
283
- alias quoted_subject subject
284
-
285
- def subject=( str )
286
- set_string_attr 'Subject', str
287
- end
288
-
289
-
290
- #
291
- # identity & threading
292
- #
293
-
294
- def message_id( default = nil )
295
- if h = @header['message-id']
296
- h.id || default
297
- else
298
- default
299
- end
300
- end
301
-
302
- def message_id=( str )
303
- set_string_attr 'Message-Id', str
304
- end
305
-
306
- def in_reply_to( default = nil )
307
- if h = @header['in-reply-to']
308
- h.ids
309
- else
310
- default
311
- end
312
- end
313
-
314
- def in_reply_to=( *idstrs )
315
- set_string_array_attr 'In-Reply-To', idstrs
316
- end
317
-
318
- def references( default = nil )
319
- if h = @header['references']
320
- h.refs
321
- else
322
- default
323
- end
324
- end
325
-
326
- def references=( *strs )
327
- set_string_array_attr 'References', strs
328
- end
329
-
330
-
331
- #
332
- # MIME headers
333
- #
334
-
335
- def mime_version( default = nil )
336
- if h = @header['mime-version']
337
- h.version || default
338
- else
339
- default
340
- end
341
- end
342
-
343
- def mime_version=( m, opt = nil )
344
- if opt
345
- if h = @header['mime-version']
346
- h.major = m
347
- h.minor = opt
348
- else
349
- store 'Mime-Version', "#{m}.#{opt}"
350
- end
351
- else
352
- store 'Mime-Version', m
353
- end
354
- m
355
- end
356
-
357
-
358
- def content_type( default = nil )
359
- if h = @header['content-type']
360
- h.content_type || default
361
- else
362
- default
363
- end
364
- end
365
-
366
- def main_type( default = nil )
367
- if h = @header['content-type']
368
- h.main_type || default
369
- else
370
- default
371
- end
372
- end
373
-
374
- def sub_type( default = nil )
375
- if h = @header['content-type']
376
- h.sub_type || default
377
- else
378
- default
379
- end
380
- end
381
-
382
- def set_content_type( str, sub = nil, param = nil )
383
- if sub
384
- main, sub = str, sub
385
- else
386
- main, sub = str.split(%r</>, 2)
387
- raise ArgumentError, "sub type missing: #{str.inspect}" unless sub
388
- end
389
- if h = @header['content-type']
390
- h.main_type = main
391
- h.sub_type = sub
392
- h.params.clear
393
- else
394
- store 'Content-Type', "#{main}/#{sub}"
395
- end
396
- @header['content-type'].params.replace param if param
397
-
398
- str
399
- end
400
-
401
- alias content_type= set_content_type
402
-
403
- def type_param( name, default = nil )
404
- if h = @header['content-type']
405
- h[name] || default
406
- else
407
- default
408
- end
409
- end
410
-
411
- def charset( default = nil )
412
- if h = @header['content-type']
413
- h['charset'] or default
414
- else
415
- default
416
- end
417
- end
418
-
419
- def charset=( str )
420
- if str
421
- if h = @header[ 'content-type' ]
422
- h['charset'] = str
423
- else
424
- store 'Content-Type', "text/plain; charset=#{str}"
425
- end
426
- end
427
- str
428
- end
429
-
430
-
431
- def transfer_encoding( default = nil )
432
- if h = @header['content-transfer-encoding']
433
- h.encoding || default
434
- else
435
- default
436
- end
437
- end
438
-
439
- def transfer_encoding=( str )
440
- set_string_attr 'Content-Transfer-Encoding', str
441
- end
442
-
443
- alias encoding transfer_encoding
444
- alias encoding= transfer_encoding=
445
- alias content_transfer_encoding transfer_encoding
446
- alias content_transfer_encoding= transfer_encoding=
447
-
448
-
449
- def disposition( default = nil )
450
- if h = @header['content-disposition']
451
- h.disposition || default
452
- else
453
- default
454
- end
455
- end
456
-
457
- alias content_disposition disposition
458
-
459
- def set_disposition( str, params = nil )
460
- if h = @header['content-disposition']
461
- h.disposition = str
462
- h.params.clear
463
- else
464
- store('Content-Disposition', str)
465
- h = @header['content-disposition']
466
- end
467
- h.params.replace params if params
468
- end
469
-
470
- alias disposition= set_disposition
471
- alias set_content_disposition set_disposition
472
- alias content_disposition= set_disposition
473
-
474
- def disposition_param( name, default = nil )
475
- if h = @header['content-disposition']
476
- h[name] || default
477
- else
478
- default
479
- end
480
- end
481
-
482
- ###
483
- ### utils
484
- ###
485
-
486
- def create_reply
487
- mail = TMail::Mail.parse('')
488
- mail.subject = 'Re: ' + subject('').sub(/\A(?:\[[^\]]+\])?(?:\s*Re:)*\s*/i, '')
489
- mail.to_addrs = reply_addresses([])
490
- mail.in_reply_to = [message_id(nil)].compact
491
- mail.references = references([]) + [message_id(nil)].compact
492
- mail.mime_version = '1.0'
493
- mail
494
- end
495
-
496
-
497
- def base64_encode
498
- store 'Content-Transfer-Encoding', 'Base64'
499
- self.body = Base64.folding_encode(self.body)
500
- end
501
-
502
- def base64_decode
503
- if /base64/i === self.transfer_encoding('')
504
- store 'Content-Transfer-Encoding', '8bit'
505
- self.body = Base64.decode(self.body, @config.strict_base64decode?)
506
- end
507
- end
508
-
509
-
510
- def destinations( default = nil )
511
- ret = []
512
- %w( to cc bcc ).each do |nm|
513
- if h = @header[nm]
514
- h.addrs.each {|i| ret.push i.address }
515
- end
516
- end
517
- ret.empty? ? default : ret
518
- end
519
-
520
- def each_destination( &block )
521
- destinations([]).each do |i|
522
- if Address === i
523
- yield i
524
- else
525
- i.each(&block)
526
- end
527
- end
528
- end
529
-
530
- alias each_dest each_destination
531
-
532
-
533
- def reply_addresses( default = nil )
534
- reply_to_addrs(nil) or from_addrs(nil) or default
535
- end
536
-
537
- def error_reply_addresses( default = nil )
538
- if s = sender(nil)
539
- [s]
540
- else
541
- from_addrs(default)
542
- end
543
- end
544
-
545
-
546
- def multipart?
547
- main_type('').downcase == 'multipart'
548
- end
549
-
550
- end # class Mail
551
-
552
- end # module TMail