mail 2.6.4 → 2.7.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +35 -0
- data/Dependencies.txt +0 -1
- data/Gemfile +7 -7
- data/README.md +8 -5
- data/Rakefile +0 -6
- data/lib/mail/attachments_list.rb +4 -3
- data/lib/mail/body.rb +3 -3
- data/lib/mail/check_delivery_params.rb +47 -10
- data/lib/mail/core_extensions/smtp.rb +19 -16
- data/lib/mail/core_extensions/string.rb +0 -4
- data/lib/mail/elements/address.rb +18 -8
- data/lib/mail/elements/address_list.rb +10 -18
- data/lib/mail/elements/content_disposition_element.rb +8 -15
- data/lib/mail/elements/content_location_element.rb +5 -10
- data/lib/mail/elements/content_transfer_encoding_element.rb +5 -10
- data/lib/mail/elements/content_type_element.rb +8 -19
- data/lib/mail/elements/date_time_element.rb +6 -14
- data/lib/mail/elements/envelope_from_element.rb +14 -21
- data/lib/mail/elements/message_ids_element.rb +8 -12
- data/lib/mail/elements/mime_version_element.rb +6 -14
- data/lib/mail/elements/phrase_list.rb +6 -9
- data/lib/mail/elements/received_element.rb +9 -15
- data/lib/mail/encodings.rb +12 -14
- data/lib/mail/field.rb +7 -4
- data/lib/mail/fields/common/address_container.rb +2 -2
- data/lib/mail/fields/common/parameter_hash.rb +1 -1
- data/lib/mail/fields/content_type_field.rb +2 -7
- data/lib/mail/fields/unstructured_field.rb +2 -2
- data/lib/mail/header.rb +1 -0
- data/lib/mail/message.rb +23 -25
- data/lib/mail/multibyte/chars.rb +29 -29
- data/lib/mail/multibyte.rb +51 -0
- data/lib/mail/network/delivery_methods/file_delivery.rb +4 -8
- data/lib/mail/network/delivery_methods/sendmail.rb +2 -4
- data/lib/mail/network/delivery_methods/smtp.rb +16 -11
- data/lib/mail/network/delivery_methods/smtp_connection.rb +2 -6
- data/lib/mail/network/delivery_methods/test_mailer.rb +5 -8
- data/lib/mail/network/retriever_methods/test_retriever.rb +1 -1
- data/lib/mail/parsers/address_lists_parser.rb +15321 -112
- data/lib/mail/parsers/address_lists_parser.rl +166 -0
- data/lib/mail/parsers/content_disposition_parser.rb +698 -55
- data/lib/mail/parsers/content_disposition_parser.rl +76 -0
- data/lib/mail/parsers/content_location_parser.rb +565 -23
- data/lib/mail/parsers/content_location_parser.rl +65 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +410 -22
- data/lib/mail/parsers/content_transfer_encoding_parser.rl +58 -0
- data/lib/mail/parsers/content_type_parser.rb +841 -54
- data/lib/mail/parsers/content_type_parser.rl +77 -0
- data/lib/mail/parsers/date_time_parser.rb +773 -26
- data/lib/mail/parsers/date_time_parser.rl +56 -0
- data/lib/mail/parsers/envelope_from_parser.rb +2051 -36
- data/lib/mail/parsers/envelope_from_parser.rl +76 -0
- data/lib/mail/parsers/message_ids_parser.rb +1494 -25
- data/lib/mail/parsers/message_ids_parser.rl +76 -0
- data/lib/mail/parsers/mime_version_parser.rb +393 -26
- data/lib/mail/parsers/mime_version_parser.rl +55 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +529 -19
- data/lib/mail/parsers/phrase_lists_parser.rl +77 -0
- data/lib/mail/parsers/received_parser.rb +4711 -38
- data/lib/mail/parsers/received_parser.rl +78 -0
- data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +12 -0
- data/lib/mail/parsers/rfc2045_content_type.rl +24 -0
- data/lib/mail/parsers/rfc2045_mime.rl +15 -0
- data/lib/mail/parsers/rfc2183_content_disposition.rl +14 -0
- data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +16 -0
- data/lib/mail/parsers/rfc5322.rl +57 -0
- data/lib/mail/parsers/rfc5322_address.rl +70 -0
- data/lib/mail/parsers/{ragel/date_time.rl → rfc5322_date_time.rl} +7 -1
- data/lib/mail/parsers/rfc5322_lexical_tokens.rl +56 -0
- data/lib/mail/parsers.rb +16 -24
- data/lib/mail/part.rb +1 -1
- data/lib/mail/parts_list.rb +5 -6
- data/lib/mail/utilities.rb +19 -3
- data/lib/mail/version.rb +3 -3
- data/lib/mail/version_specific/ruby_1_8.rb +28 -2
- data/lib/mail/version_specific/ruby_1_9.rb +51 -8
- data/lib/mail.rb +2 -10
- metadata +28 -45
- data/lib/mail/core_extensions/string/access.rb +0 -146
- data/lib/mail/core_extensions/string/multibyte.rb +0 -79
- data/lib/mail/parsers/ragel/common.rl +0 -185
- data/lib/mail/parsers/ragel/parser_info.rb +0 -61
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +0 -14864
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +0 -751
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +0 -614
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +0 -447
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +0 -825
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +0 -817
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +0 -2149
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +0 -1570
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +0 -440
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +0 -564
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +0 -51
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +0 -5144
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +0 -37
- data/lib/mail/parsers/ragel/ruby.rb +0 -40
- data/lib/mail/parsers/ragel.rb +0 -18
data/lib/mail/multibyte.rb
CHANGED
|
@@ -21,6 +21,57 @@ module Mail #:nodoc:
|
|
|
21
21
|
@proxy_class ||= Mail::Multibyte::Chars
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
if RUBY_VERSION >= "1.9"
|
|
25
|
+
# == Multibyte proxy
|
|
26
|
+
#
|
|
27
|
+
# +mb_chars+ is a multibyte safe proxy for string methods.
|
|
28
|
+
#
|
|
29
|
+
# In Ruby 1.8 and older it creates and returns an instance of the Mail::Multibyte::Chars class which
|
|
30
|
+
# encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy
|
|
31
|
+
# class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string.
|
|
32
|
+
#
|
|
33
|
+
# name = 'Claus Müller'
|
|
34
|
+
# name.reverse # => "rell??M sualC"
|
|
35
|
+
# name.length # => 13
|
|
36
|
+
#
|
|
37
|
+
# name.mb_chars.reverse.to_s # => "rellüM sualC"
|
|
38
|
+
# name.mb_chars.length # => 12
|
|
39
|
+
#
|
|
40
|
+
# In Ruby 1.9 and newer +mb_chars+ returns +self+ because String is (mostly) encoding aware. This means that
|
|
41
|
+
# it becomes easy to run one version of your code on multiple Ruby versions.
|
|
42
|
+
#
|
|
43
|
+
# == Method chaining
|
|
44
|
+
#
|
|
45
|
+
# All the methods on the Chars proxy which normally return a string will return a Chars object. This allows
|
|
46
|
+
# method chaining on the result of any of these methods.
|
|
47
|
+
#
|
|
48
|
+
# name.mb_chars.reverse.length # => 12
|
|
49
|
+
#
|
|
50
|
+
# == Interoperability and configuration
|
|
51
|
+
#
|
|
52
|
+
# The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between
|
|
53
|
+
# String and Char work like expected. The bang! methods change the internal string representation in the Chars
|
|
54
|
+
# object. Interoperability problems can be resolved easily with a +to_s+ call.
|
|
55
|
+
#
|
|
56
|
+
# For more information about the methods defined on the Chars proxy see Mail::Multibyte::Chars. For
|
|
57
|
+
# information about how to change the default Multibyte behaviour see Mail::Multibyte.
|
|
58
|
+
def self.mb_chars(str)
|
|
59
|
+
if proxy_class.consumes?(str)
|
|
60
|
+
proxy_class.new(str)
|
|
61
|
+
else
|
|
62
|
+
str
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
def self.mb_chars(str)
|
|
67
|
+
if proxy_class.wants?(str)
|
|
68
|
+
proxy_class.new(str)
|
|
69
|
+
else
|
|
70
|
+
str
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
24
75
|
# Regular expressions that describe valid byte sequences for a character
|
|
25
76
|
VALID_CHARACTER = {
|
|
26
77
|
# Borrowed from the Kconv library by Shinji KONO - (also as seen on the W3C site)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
require 'mail/check_delivery_params'
|
|
3
3
|
|
|
4
4
|
module Mail
|
|
5
|
-
|
|
6
5
|
# FileDelivery class delivers emails into multiple files based on the destination
|
|
7
6
|
# address. Each file is appended to if it already exists.
|
|
8
7
|
#
|
|
@@ -14,22 +13,20 @@ module Mail
|
|
|
14
13
|
# Make sure the path you specify with :location is writable by the Ruby process
|
|
15
14
|
# running Mail.
|
|
16
15
|
class FileDelivery
|
|
17
|
-
include Mail::CheckDeliveryParams
|
|
18
|
-
|
|
19
16
|
if RUBY_VERSION >= '1.9.1'
|
|
20
17
|
require 'fileutils'
|
|
21
18
|
else
|
|
22
19
|
require 'ftools'
|
|
23
20
|
end
|
|
24
21
|
|
|
22
|
+
attr_accessor :settings
|
|
23
|
+
|
|
25
24
|
def initialize(values)
|
|
26
25
|
self.settings = { :location => './mails' }.merge!(values)
|
|
27
26
|
end
|
|
28
|
-
|
|
29
|
-
attr_accessor :settings
|
|
30
|
-
|
|
27
|
+
|
|
31
28
|
def deliver!(mail)
|
|
32
|
-
|
|
29
|
+
Mail::CheckDeliveryParams.check(mail)
|
|
33
30
|
|
|
34
31
|
if ::File.respond_to?(:makedirs)
|
|
35
32
|
::File.makedirs settings[:location]
|
|
@@ -41,6 +38,5 @@ module Mail
|
|
|
41
38
|
::File.open(::File.join(settings[:location], File.basename(to.to_s)), 'a') { |f| "#{f.write(mail.encoded)}\r\n\r\n" }
|
|
42
39
|
end
|
|
43
40
|
end
|
|
44
|
-
|
|
45
41
|
end
|
|
46
42
|
end
|
|
@@ -38,17 +38,15 @@ module Mail
|
|
|
38
38
|
#
|
|
39
39
|
# mail.deliver!
|
|
40
40
|
class Sendmail
|
|
41
|
-
|
|
41
|
+
attr_accessor :settings
|
|
42
42
|
|
|
43
43
|
def initialize(values)
|
|
44
44
|
self.settings = { :location => '/usr/sbin/sendmail',
|
|
45
45
|
:arguments => '-i' }.merge(values)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
attr_accessor :settings
|
|
49
|
-
|
|
50
48
|
def deliver!(mail)
|
|
51
|
-
smtp_from, smtp_to, message =
|
|
49
|
+
smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
|
|
52
50
|
|
|
53
51
|
from = "-f #{self.class.shellquote(smtp_from)}"
|
|
54
52
|
to = smtp_to.map { |_to| self.class.shellquote(_to) }.join(' ')
|
|
@@ -45,9 +45,8 @@ module Mail
|
|
|
45
45
|
# hostname or update the certificate authorities trusted by your ruby. If
|
|
46
46
|
# that isn't possible, you can control this behavior with
|
|
47
47
|
# an :openssl_verify_mode setting. Its value may be either an OpenSSL
|
|
48
|
-
# verify mode constant (OpenSSL::SSL::VERIFY_NONE),
|
|
49
|
-
# the name of an OpenSSL verify mode (none, peer
|
|
50
|
-
# fail_if_no_peer_cert).
|
|
48
|
+
# verify mode constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER),
|
|
49
|
+
# or a string containing the name of an OpenSSL verify mode (none, peer).
|
|
51
50
|
#
|
|
52
51
|
# === Others
|
|
53
52
|
#
|
|
@@ -75,7 +74,7 @@ module Mail
|
|
|
75
74
|
#
|
|
76
75
|
# mail.deliver!
|
|
77
76
|
class SMTP
|
|
78
|
-
|
|
77
|
+
attr_accessor :settings
|
|
79
78
|
|
|
80
79
|
def initialize(values)
|
|
81
80
|
self.settings = { :address => "localhost",
|
|
@@ -84,30 +83,37 @@ module Mail
|
|
|
84
83
|
:user_name => nil,
|
|
85
84
|
:password => nil,
|
|
86
85
|
:authentication => nil,
|
|
86
|
+
:enable_starttls => nil,
|
|
87
87
|
:enable_starttls_auto => true,
|
|
88
88
|
:openssl_verify_mode => nil,
|
|
89
89
|
:ssl => nil,
|
|
90
|
-
:tls => nil
|
|
90
|
+
:tls => nil,
|
|
91
|
+
:open_timeout => nil,
|
|
92
|
+
:read_timeout => nil
|
|
91
93
|
}.merge!(values)
|
|
92
94
|
end
|
|
93
95
|
|
|
94
|
-
attr_accessor :settings
|
|
95
|
-
|
|
96
96
|
# Send the message via SMTP.
|
|
97
97
|
# The from and to attributes are optional. If not set, they are retrieve from the Message.
|
|
98
98
|
def deliver!(mail)
|
|
99
|
-
smtp_from, smtp_to, message =
|
|
99
|
+
smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
|
|
100
100
|
|
|
101
101
|
smtp = Net::SMTP.new(settings[:address], settings[:port])
|
|
102
102
|
if settings[:tls] || settings[:ssl]
|
|
103
103
|
if smtp.respond_to?(:enable_tls)
|
|
104
104
|
smtp.enable_tls(ssl_context)
|
|
105
105
|
end
|
|
106
|
+
elsif settings[:enable_starttls]
|
|
107
|
+
if smtp.respond_to?(:enable_starttls)
|
|
108
|
+
smtp.enable_starttls(ssl_context)
|
|
109
|
+
end
|
|
106
110
|
elsif settings[:enable_starttls_auto]
|
|
107
111
|
if smtp.respond_to?(:enable_starttls_auto)
|
|
108
112
|
smtp.enable_starttls_auto(ssl_context)
|
|
109
113
|
end
|
|
110
114
|
end
|
|
115
|
+
smtp.open_timeout = settings[:open_timeout] if settings[:open_timeout]
|
|
116
|
+
smtp.read_timeout = settings[:read_timeout] if settings[:read_timeout]
|
|
111
117
|
|
|
112
118
|
response = nil
|
|
113
119
|
smtp.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication]) do |smtp_obj|
|
|
@@ -120,7 +126,6 @@ module Mail
|
|
|
120
126
|
self
|
|
121
127
|
end
|
|
122
128
|
end
|
|
123
|
-
|
|
124
129
|
|
|
125
130
|
private
|
|
126
131
|
|
|
@@ -130,11 +135,11 @@ module Mail
|
|
|
130
135
|
openssl_verify_mode = settings[:openssl_verify_mode]
|
|
131
136
|
|
|
132
137
|
if openssl_verify_mode.kind_of?(String)
|
|
133
|
-
openssl_verify_mode =
|
|
138
|
+
openssl_verify_mode = OpenSSL::SSL.const_get("VERIFY_#{openssl_verify_mode.upcase}")
|
|
134
139
|
end
|
|
135
140
|
|
|
136
141
|
context = Net::SMTP.default_ssl_context
|
|
137
|
-
context.verify_mode = openssl_verify_mode
|
|
142
|
+
context.verify_mode = openssl_verify_mode if openssl_verify_mode
|
|
138
143
|
context.ca_path = settings[:ca_path] if settings[:ca_path]
|
|
139
144
|
context.ca_file = settings[:ca_file] if settings[:ca_file]
|
|
140
145
|
context
|
|
@@ -38,7 +38,7 @@ module Mail
|
|
|
38
38
|
#
|
|
39
39
|
# mail.deliver!
|
|
40
40
|
class SMTPConnection
|
|
41
|
-
|
|
41
|
+
attr_accessor :smtp, :settings
|
|
42
42
|
|
|
43
43
|
def initialize(values)
|
|
44
44
|
raise ArgumentError.new('A Net::SMTP object is required for this delivery method') if values[:connection].nil?
|
|
@@ -46,17 +46,13 @@ module Mail
|
|
|
46
46
|
self.settings = values
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
attr_accessor :smtp
|
|
50
|
-
attr_accessor :settings
|
|
51
|
-
|
|
52
49
|
# Send the message via SMTP.
|
|
53
50
|
# The from and to attributes are optional. If not set, they are retrieve from the Message.
|
|
54
51
|
def deliver!(mail)
|
|
55
|
-
smtp_from, smtp_to, message =
|
|
52
|
+
smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
|
|
56
53
|
response = smtp.sendmail(message, smtp_from, smtp_to)
|
|
57
54
|
|
|
58
55
|
settings[:return_response] ? response : self
|
|
59
56
|
end
|
|
60
|
-
|
|
61
57
|
end
|
|
62
58
|
end
|
|
@@ -8,10 +8,8 @@ module Mail
|
|
|
8
8
|
# It also provides a template of the minimum methods you require to implement
|
|
9
9
|
# if you want to make a custom mailer for Mail
|
|
10
10
|
class TestMailer
|
|
11
|
-
include Mail::CheckDeliveryParams
|
|
12
|
-
|
|
13
11
|
# Provides a store of all the emails sent with the TestMailer so you can check them.
|
|
14
|
-
def
|
|
12
|
+
def self.deliveries
|
|
15
13
|
@@deliveries ||= []
|
|
16
14
|
end
|
|
17
15
|
|
|
@@ -26,20 +24,19 @@ module Mail
|
|
|
26
24
|
# * length
|
|
27
25
|
# * size
|
|
28
26
|
# * and other common Array methods
|
|
29
|
-
def
|
|
27
|
+
def self.deliveries=(val)
|
|
30
28
|
@@deliveries = val
|
|
31
29
|
end
|
|
32
30
|
|
|
31
|
+
attr_accessor :settings
|
|
32
|
+
|
|
33
33
|
def initialize(values)
|
|
34
34
|
@settings = values.dup
|
|
35
35
|
end
|
|
36
|
-
|
|
37
|
-
attr_accessor :settings
|
|
38
36
|
|
|
39
37
|
def deliver!(mail)
|
|
40
|
-
|
|
38
|
+
Mail::CheckDeliveryParams.check(mail)
|
|
41
39
|
Mail::TestMailer.deliveries << mail
|
|
42
40
|
end
|
|
43
|
-
|
|
44
41
|
end
|
|
45
42
|
end
|
|
@@ -25,7 +25,7 @@ module Mail
|
|
|
25
25
|
emails_index.reverse! if options[:what] == :last
|
|
26
26
|
emails_index = case count = options[:count]
|
|
27
27
|
when :all then emails_index
|
|
28
|
-
when
|
|
28
|
+
when Integer then emails_index[0, count]
|
|
29
29
|
else
|
|
30
30
|
raise 'Invalid count option value: ' + count.inspect
|
|
31
31
|
end
|