mail 1.4.3 → 1.5.0

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.

Files changed (37) hide show
  1. data/CHANGELOG.rdoc +14 -0
  2. data/README.rdoc +6 -6
  3. data/Rakefile +1 -1
  4. data/lib/mail/body.rb +2 -2
  5. data/lib/mail/field.rb +1 -1
  6. data/lib/mail/fields/bcc_field.rb +5 -6
  7. data/lib/mail/fields/cc_field.rb +5 -4
  8. data/lib/mail/fields/comments_field.rb +3 -7
  9. data/lib/mail/fields/common/common_address.rb +8 -0
  10. data/lib/mail/fields/common/common_date.rb +4 -0
  11. data/lib/mail/fields/common/common_field.rb +5 -1
  12. data/lib/mail/fields/common/common_message_id.rb +8 -0
  13. data/lib/mail/fields/content_transfer_encoding_field.rb +1 -1
  14. data/lib/mail/fields/content_type_field.rb +4 -0
  15. data/lib/mail/fields/date_field.rb +7 -7
  16. data/lib/mail/fields/from_field.rb +5 -4
  17. data/lib/mail/fields/in_reply_to_field.rb +2 -3
  18. data/lib/mail/fields/keywords_field.rb +4 -0
  19. data/lib/mail/fields/message_id_field.rb +3 -4
  20. data/lib/mail/fields/references_field.rb +2 -3
  21. data/lib/mail/fields/reply_to_field.rb +5 -4
  22. data/lib/mail/fields/resent_bcc_field.rb +5 -4
  23. data/lib/mail/fields/resent_cc_field.rb +5 -4
  24. data/lib/mail/fields/resent_date_field.rb +9 -1
  25. data/lib/mail/fields/resent_from_field.rb +6 -5
  26. data/lib/mail/fields/resent_sender_field.rb +1 -1
  27. data/lib/mail/fields/resent_to_field.rb +5 -4
  28. data/lib/mail/fields/sender_field.rb +6 -5
  29. data/lib/mail/fields/structured_field.rb +4 -0
  30. data/lib/mail/fields/to_field.rb +5 -4
  31. data/lib/mail/fields/unstructured_field.rb +4 -0
  32. data/lib/mail/header.rb +4 -3
  33. data/lib/mail/message.rb +619 -105
  34. data/lib/mail/network/delivery_methods/smtp.rb +1 -1
  35. data/lib/mail/utilities.rb +14 -3
  36. data/lib/mail/version.rb +2 -2
  37. metadata +2 -2
@@ -1,3 +1,17 @@
1
+ == Sun Jan 3 00:08:06 UTC 2010 Mikel Lindsaar <raasdnil@gmail.com>
2
+
3
+ * Version bump to 1.5.0
4
+
5
+ * Major API change in Message#field_name. This WILL break your applications that use Mail. Message#field_name now returns good, intelligent, default values. You can still access the field object by calling Message#[:field_name] or Message#['field_name'].
6
+
7
+ == Sat Jan 2 04:12:53 UTC 2010 Mikel Lindsaar <raasdnil@gmail.com>
8
+
9
+ * Message-ID, Content-ID, References et al, now return the default value of the message ID without the angle brackets, as per RFC 2822, "Semantically, the angle bracket characters are not part of the msg-id; the msg-id is what is contained between the two angle bracket characters."
10
+
11
+ * Message class now has getter and setter methods for all the supported field types explicitly. This allows us to return a "default" value for all fields.
12
+
13
+ * All address fields, when called from Message#to or Message#from or the like, return either a string of the address spec (mikel@test.lindsaar.net) if it is a single entry, or an array of address specs if there is more than one ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
14
+
1
15
  == Mon 28 Dec 2009 01:21:52 UTC Mikel Lindsaar <raasdnil@gmail.com>
2
16
 
3
17
  * Added sorting of parts, default is text/plain, then text/enriched and text/html. Access through Body#set_sort_order and Body#sort_parts! (called from Body#encode automatically)
@@ -290,12 +290,12 @@ Or even all emails:
290
290
  mail.envelope.from #=> 'mikel@test.lindsaar.net'
291
291
  mail.from.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
292
292
  mail.sender.address #=> 'mikel@test.lindsaar.net'
293
- mail.to.addresses #=> ['bob@test.lindsaar.net']
294
- mail.cc.addresses #=> ['sam@test.lindsaar.net']
295
- mail.subject.to_s #=> "This is the subject"
293
+ mail.to #=> 'bob@test.lindsaar.net'
294
+ mail.cc #=> 'sam@test.lindsaar.net'
295
+ mail.subject #=> "This is the subject"
296
296
  mail.date.to_s #=> '21 Nov 1997 09:55:06 -0600'
297
297
  mail.message_id #=> '<4D6AA7EB.6490534@xxx.xxx>'
298
- mail.body #=> 'This is the body of the email...
298
+ mail.body.decoded #=> 'This is the body of the email...
299
299
 
300
300
  Many more methods available.
301
301
 
@@ -311,8 +311,8 @@ Many more methods available.
311
311
  mail.epilogue #=> "Text after the last part"
312
312
  mail.parts.map { |p| p.content_type } #=> ['text/plain', 'application/pdf']
313
313
  mail.parts.map { |p| p.class } #=> [Mail::Message, Mail::Message]
314
- mail.parts[0].mime_parameters #=> {'charset' => 'ISO-8859-1'}
315
- mail.parts[1].mime_parameters #=> {'name' => 'my.pdf'}
314
+ mail.parts[0].content_type_parameters #=> {'charset' => 'ISO-8859-1'}
315
+ mail.parts[1].content_type_parameters #=> {'name' => 'my.pdf'}
316
316
 
317
317
  Mail generates a tree of parts. Each message has many or no parts. Each part
318
318
  is another message which can have many or no parts.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'bundler'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = "mail"
15
- s.version = "1.4.3"
15
+ s.version = "1.5.0"
16
16
  s.author = "Mike Lindsaar"
17
17
  s.email = "raasdnil@gmail.com"
18
18
  s.homepage = "http://github.com/mikel/mail"
@@ -108,8 +108,8 @@ module Mail
108
108
  # OK, 10000 is arbitrary... if anyone actually wants to explicitly sort 10000 parts of a
109
109
  # single email message... please show me a use case and I'll put more work into this method,
110
110
  # in the meantime, it works :)
111
- a_order = order.index(a.content_type.string.downcase) || 10000
112
- b_order = order.index(b.content_type.string.downcase) || 10000
111
+ a_order = order.index(a[:content_type].string.downcase) || 10000
112
+ b_order = order.index(b[:content_type].string.downcase) || 10000
113
113
  a_order <=> b_order
114
114
  end
115
115
  end
@@ -69,7 +69,7 @@ module Mail
69
69
  case
70
70
  when name =~ /:/ && value.blank? # Field.new("field-name: field data")
71
71
  name, value = split(name)
72
- create_field(name, value.to_s)
72
+ create_field(name, value)
73
73
  when name !~ /:/ && value.blank? # Field.new("field-name")
74
74
  create_field(name, nil)
75
75
  else # Field.new("field-name", "value")
@@ -16,16 +16,15 @@
16
16
  #
17
17
  # mail = Mail.new
18
18
  # mail.bcc = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
- # mail.bcc #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::BccField:0x180e1c4
19
+ # mail.bcc #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
20
  # mail[:bcc] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::BccField:0x180e1c4
21
21
  # mail['bcc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::BccField:0x180e1c4
22
22
  # mail['Bcc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::BccField:0x180e1c4
23
23
  #
24
- # mail.bcc.to_s #=> '' # Bcc field does not get output into an email
25
- # mail.bcc.encoded #=> '' # Bcc field does not get output into an email
26
- # mail.bcc.decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
27
- # mail.bcc.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
28
- # mail.bcc.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
24
+ # mail[:bcc].encoded #=> '' # Bcc field does not get output into an email
25
+ # mail[:bcc].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:bcc].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:bcc].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
29
28
  #
30
29
  module Mail
31
30
  class BccField < StructuredField
@@ -16,14 +16,15 @@
16
16
  #
17
17
  # mail = Mail.new
18
18
  # mail.cc = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
- # mail.cc #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CcField:0x180e1c4
19
+ # mail.cc #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
20
  # mail[:cc] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CcField:0x180e1c4
21
21
  # mail['cc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CcField:0x180e1c4
22
22
  # mail['Cc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CcField:0x180e1c4
23
23
  #
24
- # mail.cc.to_s #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
25
- # mail.cc.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
26
- # mail.cc.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
24
+ # mail[:cc].encoded #=> 'Cc: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:cc].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:cc].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:cc].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
27
28
  #
28
29
  module Mail
29
30
  class CcField < StructuredField
@@ -15,19 +15,15 @@
15
15
  #
16
16
  # mail = Mail.new
17
17
  # mail.comments = 'This is a comment'
18
- # mail.comments #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CommentsField:0x180e1c4
18
+ # mail.comments #=> 'This is a comment'
19
19
  # mail[:comments] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CommentsField:0x180e1c4
20
20
  # mail['comments'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CommentsField:0x180e1c4
21
21
  # mail['comments'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::CommentsField:0x180e1c4
22
22
  #
23
- # mail.comments.to_s #=> 'This is a comment'
24
- #
25
23
  # mail.comments = "This is another comment"
26
- # mail.comments.map { |c| c.to_s }
24
+ # mail[:comments].map { |c| c.to_s }
27
25
  # #=> ['This is a comment', "This is another comment"]
28
- # mail.comments.to_s # Probably not what you want to do in this case
29
- # #=> "This is a commentThis is another comment"
30
- #
26
+ #
31
27
  module Mail
32
28
  class CommentsField < UnstructuredField
33
29
 
@@ -44,6 +44,14 @@ module Mail
44
44
  tree.group_names
45
45
  end
46
46
 
47
+ def default
48
+ if addresses.length == 1
49
+ addresses[0]
50
+ else
51
+ addresses
52
+ end
53
+ end
54
+
47
55
  private
48
56
 
49
57
  def do_encode(field_name)
@@ -9,6 +9,10 @@ module Mail
9
9
  ::DateTime.parse("#{element.date_string} #{element.time_string}")
10
10
  end
11
11
 
12
+ def default
13
+ date_time
14
+ end
15
+
12
16
  private
13
17
 
14
18
  def do_encode(field_name)
@@ -31,6 +31,10 @@ module Mail
31
31
  decoded
32
32
  end
33
33
 
34
+ def default
35
+ decoded
36
+ end
37
+
34
38
  def field_length
35
39
  @length ||= name.length + value.length + ': '.length
36
40
  end
@@ -41,7 +45,7 @@ module Mail
41
45
 
42
46
  private
43
47
 
44
- def strip_field(field_name, string)
48
+ def strip_field(field_name, string)
45
49
  string.to_s.gsub(/#{field_name}:\s+/i, '')
46
50
  end
47
51
 
@@ -24,6 +24,14 @@ module Mail
24
24
  element.message_ids
25
25
  end
26
26
 
27
+ def default
28
+ if message_ids.length == 1
29
+ message_ids[0]
30
+ else
31
+ message_ids
32
+ end
33
+ end
34
+
27
35
  private
28
36
 
29
37
  def do_encode(field_name)
@@ -33,6 +33,6 @@ module Mail
33
33
  def decoded
34
34
  value
35
35
  end
36
-
36
+
37
37
  end
38
38
  end
@@ -45,6 +45,10 @@ module Mail
45
45
  "#{main_type}/#{sub_type}"
46
46
  end
47
47
 
48
+ def default
49
+ decoded
50
+ end
51
+
48
52
  alias :content_type :string
49
53
 
50
54
  def parameters
@@ -15,13 +15,11 @@
15
15
  #
16
16
  # mail = Mail.new
17
17
  # mail.date = 'Mon, 24 Nov 1997 14:22:01 -0800'
18
- # mail.date #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
19
- # mail[:date] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
20
- # mail['date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
21
- # mail['Date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
22
- #
18
+ # mail.date #=> #<DateTime: 211747170121/86400,-1/3,2299161>
23
19
  # mail.date.to_s #=> 'Mon, 24 Nov 1997 14:22:01 -0800'
24
- # mail.date.date_time #=> #<DateTime: 211747170121/86400,-1/3,2299161>
20
+ # mail[:date] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
21
+ # mail['date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
22
+ # mail['Date'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::DateField:0x180e1c4
25
23
  #
26
24
  module Mail
27
25
  class DateField < StructuredField
@@ -37,7 +35,9 @@ module Mail
37
35
  self.value = Time.now.strftime('%a, %d %b %Y %H:%M:%S %z')
38
36
  self
39
37
  else
40
- super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
38
+ value = strip_field(FIELD_NAME, args.last)
39
+ value = ::DateTime.parse(value.to_s).strftime('%a, %d %b %Y %H:%M:%S %z')
40
+ super(CAPITALIZED_FIELD, value)
41
41
  end
42
42
  end
43
43
 
@@ -16,14 +16,15 @@
16
16
  #
17
17
  # mail = Mail.new
18
18
  # mail.from = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
- # mail.from #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
19
+ # mail.from #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
20
  # mail[:from] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
21
21
  # mail['from'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
22
22
  # mail['From'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::FromField:0x180e1c4
23
23
  #
24
- # mail.from.to_s #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
25
- # mail.from.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
26
- # mail.from.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
24
+ # mail[:from].encoded #=> 'from: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:from].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:from].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:from].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
27
28
  #
28
29
  module Mail
29
30
  class FromField < StructuredField
@@ -19,13 +19,12 @@
19
19
  #
20
20
  # mail = Mail.new
21
21
  # mail.in_reply_to = '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
22
- # mail.in_reply_to #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::InReplyToField:0x180e1c4
22
+ # mail.in_reply_to #=> '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
23
23
  # mail[:in_reply_to] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::InReplyToField:0x180e1c4
24
24
  # mail['in_reply_to'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::InReplyToField:0x180e1c4
25
25
  # mail['In-Reply-To'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::InReplyToField:0x180e1c4
26
26
  #
27
- # mail.in_reply_to.to_s #=> '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
28
- # mail.in_reply_to.message_ids #=> ['F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom']
27
+ # mail[:in_reply_to].message_ids #=> ['F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom']
29
28
  #
30
29
  module Mail
31
30
  class InReplyToField < StructuredField
@@ -26,6 +26,10 @@ module Mail
26
26
  def decoded
27
27
  keywords.join(', ')
28
28
  end
29
+
30
+ def default
31
+ keywords
32
+ end
29
33
 
30
34
  end
31
35
  end
@@ -20,14 +20,13 @@
20
20
  #
21
21
  # mail = Mail.new
22
22
  # mail.message_id = '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
23
- # mail.message_id #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::MessageIdField:0x180e1c4
23
+ # mail.message_id #=> '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
24
24
  # mail[:message_id] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::MessageIdField:0x180e1c4
25
25
  # mail['message_id'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::MessageIdField:0x180e1c4
26
26
  # mail['Message-ID'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::MessageIdField:0x180e1c4
27
27
  #
28
- # mail.message_id.to_s #=> '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
29
- # mail.message_id.message_id #=> 'F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom'
30
- # mail.message_id.message_ids #=> ['F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom']
28
+ # mail[:message_id].message_id #=> 'F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom'
29
+ # mail[:message_id].message_ids #=> ['F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom']
31
30
  #
32
31
  module Mail
33
32
  class MessageIdField < StructuredField
@@ -19,13 +19,12 @@
19
19
  #
20
20
  # mail = Mail.new
21
21
  # mail.references = '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
22
- # mail.references #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReferencesField:0x180e1c4
22
+ # mail.references #=> '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
23
23
  # mail[:references] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReferencesField:0x180e1c4
24
24
  # mail['references'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReferencesField:0x180e1c4
25
25
  # mail['References'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReferencesField:0x180e1c4
26
26
  #
27
- # mail.references.to_s #=> '<F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom>'
28
- # mail.references.message_ids #=> ['F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom']
27
+ # mail[:references].message_ids #=> ['F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@test.me.dom']
29
28
  #
30
29
  module Mail
31
30
  class ReferencesField < StructuredField
@@ -16,14 +16,15 @@
16
16
  #
17
17
  # mail = Mail.new
18
18
  # mail.reply_to = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
- # mail.reply_to #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReplyToField:0x180e1c4
19
+ # mail.reply_to #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
20
  # mail[:reply_to] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReplyToField:0x180e1c4
21
21
  # mail['reply-to'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReplyToField:0x180e1c4
22
22
  # mail['Reply-To'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ReplyToField:0x180e1c4
23
23
  #
24
- # mail.reply_to.to_s #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
25
- # mail.reply_to.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
26
- # mail.reply_to.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
24
+ # mail[:reply_to].encoded #=> 'Reply-To: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:reply_to].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:reply_to].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:reply_to].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
27
28
  #
28
29
  module Mail
29
30
  class ReplyToField < StructuredField
@@ -16,14 +16,15 @@
16
16
  #
17
17
  # mail = Mail.new
18
18
  # mail.resent_bcc = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
- # mail.resent_bcc #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentBccField:0x180e1c4
19
+ # mail.resent_bcc #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
20
  # mail[:resent_bcc] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentBccField:0x180e1c4
21
21
  # mail['resent-bcc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentBccField:0x180e1c4
22
22
  # mail['Resent-Bcc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentBccField:0x180e1c4
23
23
  #
24
- # mail.resent_bcc.to_s #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
25
- # mail.resent_bcc.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
26
- # mail.resent_bcc.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
24
+ # mail[:resent_bcc].encoded #=> 'Resent-Bcc: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:resent_bcc].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:resent_bcc].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:resent_bcc].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
27
28
  #
28
29
  module Mail
29
30
  class ResentBccField < StructuredField
@@ -16,14 +16,15 @@
16
16
  #
17
17
  # mail = Mail.new
18
18
  # mail.resent_cc = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
- # mail.resent_cc #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentCcField:0x180e1c4
19
+ # mail.resent_cc #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
20
  # mail[:resent_cc] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentCcField:0x180e1c4
21
21
  # mail['resent-cc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentCcField:0x180e1c4
22
22
  # mail['Resent-Cc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentCcField:0x180e1c4
23
23
  #
24
- # mail.resent_cc.to_s #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
25
- # mail.resent_cc.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
26
- # mail.resent_cc.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
24
+ # mail[:resent_cc].encoded #=> 'Resent-Cc: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:resent_cc].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:resent_cc].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:resent_cc].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
27
28
  #
28
29
  module Mail
29
30
  class ResentCcField < StructuredField
@@ -10,7 +10,15 @@ module Mail
10
10
  CAPITALIZED_FIELD = 'Resent-Date'
11
11
 
12
12
  def initialize(*args)
13
- super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
13
+ if args.last.blank?
14
+ self.name = CAPITALIZED_FIELD
15
+ self.value = Time.now.strftime('%a, %d %b %Y %H:%M:%S %z')
16
+ self
17
+ else
18
+ value = strip_field(FIELD_NAME, args.last)
19
+ value = ::DateTime.parse(value.to_s).strftime('%a, %d %b %Y %H:%M:%S %z')
20
+ super(CAPITALIZED_FIELD, value)
21
+ end
14
22
  end
15
23
 
16
24
  def encoded
@@ -13,17 +13,18 @@
13
13
  # addresses and groups of addresses.
14
14
  #
15
15
  # == Examples:
16
- #
16
+ #
17
17
  # mail = Mail.new
18
18
  # mail.resent_from = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
- # mail.resent_from #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentFromField:0x180e1c4
19
+ # mail.resent_from #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
20
  # mail[:resent_from] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentFromField:0x180e1c4
21
21
  # mail['resent-from'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentFromField:0x180e1c4
22
22
  # mail['Resent-From'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentFromField:0x180e1c4
23
23
  #
24
- # mail.resent_from.to_s #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
25
- # mail.resent_from.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
26
- # mail.resent_from.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
24
+ # mail[:resent_from].encoded #=> 'Resent-From: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:resent_from].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:resent_from].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:resent_from].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
27
28
  #
28
29
  module Mail
29
30
  class ResentFromField < StructuredField