mail 1.6.0 → 2.0.3
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 +37 -0
- data/README.rdoc +9 -10
- data/Rakefile +1 -1
- data/lib/mail.rb +3 -3
- data/lib/mail/attachments_list.rb +76 -0
- data/lib/mail/body.rb +16 -16
- data/lib/mail/configuration.rb +35 -111
- data/lib/mail/encodings/encodings.rb +4 -0
- data/lib/mail/fields/common/address_container.rb +16 -0
- data/lib/mail/fields/common/common_address.rb +28 -3
- data/lib/mail/fields/return_path_field.rb +4 -0
- data/lib/mail/mail.rb +69 -57
- data/lib/mail/message.rb +169 -58
- data/lib/mail/network/delivery_methods/file_delivery.rb +32 -10
- data/lib/mail/network/delivery_methods/sendmail.rb +52 -14
- data/lib/mail/network/delivery_methods/smtp.rb +85 -68
- data/lib/mail/network/delivery_methods/test_mailer.rb +7 -2
- data/lib/mail/network/retriever_methods/imap.rb +7 -6
- data/lib/mail/network/retriever_methods/pop3.rb +48 -73
- data/lib/mail/parts_list.rb +34 -0
- data/lib/mail/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic.rb +1 -1
- data/lib/mail/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus.rb +1 -1
- data/lib/mail/vendor/treetop-1.4.3/lib/treetop/compiler/metagrammar.rb +1 -1
- data/lib/mail/vendor/treetop.rb +1 -1
- data/lib/mail/version.rb +3 -3
- metadata +5 -5
- data/lib/mail/attachment.rb +0 -107
- data/lib/mail/network/deliverable.rb +0 -15
- data/lib/mail/network/retrievable.rb +0 -19
@@ -0,0 +1,34 @@
|
|
1
|
+
module Mail
|
2
|
+
class PartsList < Array
|
3
|
+
|
4
|
+
def attachments
|
5
|
+
Mail::AttachmentsList.new(self)
|
6
|
+
end
|
7
|
+
|
8
|
+
def collect
|
9
|
+
if block_given?
|
10
|
+
ary = PartsList.new
|
11
|
+
each { |o| ary << yield(o) }
|
12
|
+
ary
|
13
|
+
else
|
14
|
+
to_a
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
alias :collect :map
|
19
|
+
|
20
|
+
def sort!(order)
|
21
|
+
sorted = self.sort do |a, b|
|
22
|
+
# OK, 10000 is arbitrary... if anyone actually wants to explicitly sort 10000 parts of a
|
23
|
+
# single email message... please show me a use case and I'll put more work into this method,
|
24
|
+
# in the meantime, it works :)
|
25
|
+
a_order = order.index(a[:content_type].string.downcase) || 10000
|
26
|
+
b_order = order.index(b[:content_type].string.downcase) || 10000
|
27
|
+
a_order <=> b_order
|
28
|
+
end
|
29
|
+
self.clear
|
30
|
+
sorted.each { |p| self << p }
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/mail/vendor/treetop.rb
CHANGED
data/lib/mail/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Lindsaar
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-23 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -46,7 +46,7 @@ files:
|
|
46
46
|
- README.rdoc
|
47
47
|
- Rakefile
|
48
48
|
- TODO.rdoc
|
49
|
-
- lib/mail/
|
49
|
+
- lib/mail/attachments_list.rb
|
50
50
|
- lib/mail/body.rb
|
51
51
|
- lib/mail/configuration.rb
|
52
52
|
- lib/mail/core_extensions/nil.rb
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/mail/fields/bcc_field.rb
|
73
73
|
- lib/mail/fields/cc_field.rb
|
74
74
|
- lib/mail/fields/comments_field.rb
|
75
|
+
- lib/mail/fields/common/address_container.rb
|
75
76
|
- lib/mail/fields/common/common_address.rb
|
76
77
|
- lib/mail/fields/common/common_date.rb
|
77
78
|
- lib/mail/fields/common/common_field.rb
|
@@ -109,12 +110,10 @@ files:
|
|
109
110
|
- lib/mail/header.rb
|
110
111
|
- lib/mail/mail.rb
|
111
112
|
- lib/mail/message.rb
|
112
|
-
- lib/mail/network/deliverable.rb
|
113
113
|
- lib/mail/network/delivery_methods/file_delivery.rb
|
114
114
|
- lib/mail/network/delivery_methods/sendmail.rb
|
115
115
|
- lib/mail/network/delivery_methods/smtp.rb
|
116
116
|
- lib/mail/network/delivery_methods/test_mailer.rb
|
117
|
-
- lib/mail/network/retrievable.rb
|
118
117
|
- lib/mail/network/retriever_methods/imap.rb
|
119
118
|
- lib/mail/network/retriever_methods/pop3.rb
|
120
119
|
- lib/mail/parsers/address_lists.rb
|
@@ -146,6 +145,7 @@ files:
|
|
146
145
|
- lib/mail/parsers/rfc2822_obsolete.rb
|
147
146
|
- lib/mail/parsers/rfc2822_obsolete.treetop
|
148
147
|
- lib/mail/part.rb
|
148
|
+
- lib/mail/parts_list.rb
|
149
149
|
- lib/mail/patterns.rb
|
150
150
|
- lib/mail/utilities.rb
|
151
151
|
- lib/mail/vendor/treetop-1.4.3/benchmark/seqpar.gnuplot
|
data/lib/mail/attachment.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Mail
|
3
|
-
# An attachment is any data you want to attach to a mail message that is
|
4
|
-
# not part of the body and can be extracted to a file in it's own right
|
5
|
-
#
|
6
|
-
# This includes images, sound files, text files, documents, anything really,
|
7
|
-
# the only requisite is that it has a file name and an encoding.
|
8
|
-
#
|
9
|
-
# If you do not pass in an encoding when creating a new attachment, then
|
10
|
-
# Mail::Attachment will assume that the data you pass in is raw data and
|
11
|
-
# encode it with base64.
|
12
|
-
#
|
13
|
-
# If you pass in an encoding, Mail::Attachment will assume that the data
|
14
|
-
# is encoded data and attempt to decode the data string with the encoding
|
15
|
-
# you supply.
|
16
|
-
#
|
17
|
-
# So, raw data should be given in with no encoding, pre encoded data should
|
18
|
-
# be given with an encoding type.
|
19
|
-
#
|
20
|
-
# Attachment will always encode with Base64, it's safe, it works, maybe in
|
21
|
-
# the future we will allow you to encode with different types. If you really
|
22
|
-
# want to encode with a different encoder, then pre encode the data and pass
|
23
|
-
# it in with an encoding. Mail::Attachment will happily initialize for you,
|
24
|
-
# however, if it doesn't understand the encoding, it will not decode for you
|
25
|
-
# and raise an error, but if you can encode it, we assume you know how to
|
26
|
-
# decode it, so just get back the encoded source (with #encoded) and then
|
27
|
-
# decode at your leisure.
|
28
|
-
class Attachment
|
29
|
-
|
30
|
-
include Utilities
|
31
|
-
|
32
|
-
# Raised when attempting to decode an unknown encoding type
|
33
|
-
class UnknownEncodingType < StandardError #:nodoc:
|
34
|
-
end
|
35
|
-
|
36
|
-
def initialize(options_hash)
|
37
|
-
case
|
38
|
-
when options_hash[:data]
|
39
|
-
if options_hash[:filename].respond_to?(:force_encoding)
|
40
|
-
encoding = options_hash[:filename].encoding
|
41
|
-
filename = File.basename(options_hash[:filename].force_encoding(Encoding::BINARY))
|
42
|
-
@filename = filename.force_encoding(encoding)
|
43
|
-
else
|
44
|
-
@filename = File.basename(options_hash[:filename])
|
45
|
-
end
|
46
|
-
|
47
|
-
add_file(options_hash[:data], options_hash[:encoding])
|
48
|
-
when options_hash[:filename]
|
49
|
-
@filename = File.basename(options_hash[:filename])
|
50
|
-
data = File.read(options_hash[:filename])
|
51
|
-
add_file(data, options_hash[:encoding])
|
52
|
-
end
|
53
|
-
set_mime_type(@filename, options_hash[:mime_type])
|
54
|
-
end
|
55
|
-
|
56
|
-
def filename
|
57
|
-
@filename
|
58
|
-
end
|
59
|
-
|
60
|
-
alias :original_filename :filename
|
61
|
-
|
62
|
-
def encoded
|
63
|
-
@encoded_data
|
64
|
-
end
|
65
|
-
|
66
|
-
def decoded
|
67
|
-
if Mail::Encodings.defined?(@encoding)
|
68
|
-
Mail::Encodings.get_encoding(@encoding).decode(@encoded_data)
|
69
|
-
else
|
70
|
-
raise UnknownEncodingType, "Don't know how to decode #{@encoding}, please call #encoded and decode it yourself."
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
alias :read :decoded
|
75
|
-
|
76
|
-
def mime_type
|
77
|
-
@mime_type.to_s
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def set_mime_type(filename, mime_type)
|
83
|
-
unless mime_type
|
84
|
-
# Have to do this because MIME::Types is not Ruby 1.9 safe yet
|
85
|
-
if RUBY_VERSION >= '1.9'
|
86
|
-
new_file = String.new(filename).force_encoding(Encoding::BINARY)
|
87
|
-
ext = new_file.split('.'.force_encoding(Encoding::BINARY)).last
|
88
|
-
filename = "file.#{ext}".force_encoding('US-ASCII')
|
89
|
-
end
|
90
|
-
@mime_type = MIME::Types.type_for(filename).first
|
91
|
-
else
|
92
|
-
@mime_type = mime_type
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def add_file(data, encoding)
|
97
|
-
if encoding # We are being given encoded data
|
98
|
-
@encoded_data = data
|
99
|
-
@encoding = encoding.to_s
|
100
|
-
else # this is raw data
|
101
|
-
@encoded_data = Mail::Encodings::Base64.encode(data)
|
102
|
-
@encoding = 'base64'
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Mail
|
3
|
-
# The deliverable class provides the way mail will send an email out when you
|
4
|
-
# are using the Mail.deliver! &block command or when you call Mail.deliver!(message)
|
5
|
-
#
|
6
|
-
# The default delivery is SMTP, localhost, port 25. You can change this through the
|
7
|
-
# Mail.defaults call.s
|
8
|
-
module Deliverable
|
9
|
-
|
10
|
-
def self.perform_delivery!(mail)
|
11
|
-
Mail.defaults.delivery_method.deliver!(mail)
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Include this module to retrieve emails via POP3. Each email retrieved is given to a new instance of the "includer".
|
4
|
-
# This module uses the defaults set in Configuration to retrieve POP3 settings.
|
5
|
-
#
|
6
|
-
# Thanks to Nicolas Fouché for this wrapper
|
7
|
-
#
|
8
|
-
module Mail
|
9
|
-
module Retrievable
|
10
|
-
|
11
|
-
module_function
|
12
|
-
|
13
|
-
def method_missing(name, *args, &block)
|
14
|
-
Mail.defaults.retriever_method.__send__(name, *args, &block)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|