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.
- data/CHANGELOG.rdoc +14 -0
- data/README.rdoc +6 -6
- data/Rakefile +1 -1
- data/lib/mail/body.rb +2 -2
- data/lib/mail/field.rb +1 -1
- data/lib/mail/fields/bcc_field.rb +5 -6
- data/lib/mail/fields/cc_field.rb +5 -4
- data/lib/mail/fields/comments_field.rb +3 -7
- data/lib/mail/fields/common/common_address.rb +8 -0
- data/lib/mail/fields/common/common_date.rb +4 -0
- data/lib/mail/fields/common/common_field.rb +5 -1
- data/lib/mail/fields/common/common_message_id.rb +8 -0
- data/lib/mail/fields/content_transfer_encoding_field.rb +1 -1
- data/lib/mail/fields/content_type_field.rb +4 -0
- data/lib/mail/fields/date_field.rb +7 -7
- data/lib/mail/fields/from_field.rb +5 -4
- data/lib/mail/fields/in_reply_to_field.rb +2 -3
- data/lib/mail/fields/keywords_field.rb +4 -0
- data/lib/mail/fields/message_id_field.rb +3 -4
- data/lib/mail/fields/references_field.rb +2 -3
- data/lib/mail/fields/reply_to_field.rb +5 -4
- data/lib/mail/fields/resent_bcc_field.rb +5 -4
- data/lib/mail/fields/resent_cc_field.rb +5 -4
- data/lib/mail/fields/resent_date_field.rb +9 -1
- data/lib/mail/fields/resent_from_field.rb +6 -5
- data/lib/mail/fields/resent_sender_field.rb +1 -1
- data/lib/mail/fields/resent_to_field.rb +5 -4
- data/lib/mail/fields/sender_field.rb +6 -5
- data/lib/mail/fields/structured_field.rb +4 -0
- data/lib/mail/fields/to_field.rb +5 -4
- data/lib/mail/fields/unstructured_field.rb +4 -0
- data/lib/mail/header.rb +4 -3
- data/lib/mail/message.rb +619 -105
- data/lib/mail/network/delivery_methods/smtp.rb +1 -1
- data/lib/mail/utilities.rb +14 -3
- data/lib/mail/version.rb +2 -2
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -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)
|
data/README.rdoc
CHANGED
@@ -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
|
294
|
-
mail.cc
|
295
|
-
mail.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
|
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].
|
315
|
-
mail.parts[1].
|
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
data/lib/mail/body.rb
CHANGED
@@ -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
|
112
|
-
b_order = order.index(b
|
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
|
data/lib/mail/field.rb
CHANGED
@@ -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
|
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 #=> '
|
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
|
25
|
-
# mail
|
26
|
-
# mail
|
27
|
-
# mail
|
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
|
data/lib/mail/fields/cc_field.rb
CHANGED
@@ -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 #=> '
|
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
|
25
|
-
# mail
|
26
|
-
# mail
|
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 #=> '
|
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
|
24
|
+
# mail[:comments].map { |c| c.to_s }
|
27
25
|
# #=> ['This is a comment', "This is another comment"]
|
28
|
-
#
|
29
|
-
# #=> "This is a commentThis is another comment"
|
30
|
-
#
|
26
|
+
#
|
31
27
|
module Mail
|
32
28
|
class CommentsField < UnstructuredField
|
33
29
|
|
@@ -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
|
|
@@ -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
|
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
|
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
|
-
|
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 #=> '
|
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
|
25
|
-
# mail
|
26
|
-
# mail
|
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 #=> '
|
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
|
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
|
@@ -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 #=> '
|
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
|
29
|
-
# mail
|
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 #=> '
|
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
|
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 #=> '
|
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
|
25
|
-
# mail
|
26
|
-
# mail
|
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 #=> '
|
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
|
25
|
-
# mail
|
26
|
-
# mail
|
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 #=> '
|
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
|
25
|
-
# mail
|
26
|
-
# mail
|
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
|
-
|
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 #=> '
|
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
|
25
|
-
# mail
|
26
|
-
# mail
|
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
|