mail 2.6.5 → 2.6.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +5 -0
- data/lib/mail/check_delivery_params.rb +47 -10
- 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 +2 -5
- 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/version.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff722f1c50918ad8e99f86995d08b803d32f745e
|
4
|
+
data.tar.gz: f552360cabc519f3fc959e6c193ef1d37d55670e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ff2add4d33b0e7ee9b8fc7b4473fcaf8cb7b581d6dbda1a3e6e6a46ed19d1f25c1a614e6ad142eb05982d47078eee4828f27aa76e48101822fba7ebbc78175
|
7
|
+
data.tar.gz: 48904e5d7a407ed85c7ef7be12dd1bd2e70042db1d99d9b1ff66a9af693862f3697498bbb2784a29900926d68e1a22d8bfad8e7b538a3bc26733a72660e35387
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,21 +1,58 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Mail
|
3
|
-
module CheckDeliveryParams
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module CheckDeliveryParams #:nodoc:
|
4
|
+
class << self
|
5
|
+
def check(mail)
|
6
|
+
[ check_from(mail.smtp_envelope_from),
|
7
|
+
check_to(mail.smtp_envelope_to),
|
8
|
+
check_message(mail) ]
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
def check_from(addr)
|
12
|
+
if Utilities.blank?(addr)
|
13
|
+
raise ArgumentError, "SMTP From address may not be blank: #{addr.inspect}"
|
14
|
+
end
|
15
|
+
|
16
|
+
check_addr 'From', addr
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_to(addrs)
|
20
|
+
if Utilities.blank?(addrs)
|
21
|
+
raise ArgumentError, "SMTP To address may not be blank: #{addrs.inspect}"
|
22
|
+
end
|
23
|
+
|
24
|
+
Array(addrs).map do |addr|
|
25
|
+
check_addr 'To', addr
|
26
|
+
end
|
11
27
|
end
|
12
28
|
|
13
|
-
|
14
|
-
|
15
|
-
|
29
|
+
def check_addr(addr_name, addr)
|
30
|
+
validate_smtp_addr addr do |error_message|
|
31
|
+
raise ArgumentError, "SMTP #{addr_name} address #{error_message}: #{addr.inspect}"
|
32
|
+
end
|
16
33
|
end
|
17
34
|
|
18
|
-
|
35
|
+
def validate_smtp_addr(addr)
|
36
|
+
if addr.bytesize > 2048
|
37
|
+
yield 'may not exceed 2kB'
|
38
|
+
end
|
39
|
+
|
40
|
+
if /[\r\n]/ =~ addr
|
41
|
+
yield 'may not contain CR or LF line breaks'
|
42
|
+
end
|
43
|
+
|
44
|
+
addr
|
45
|
+
end
|
46
|
+
|
47
|
+
def check_message(message)
|
48
|
+
message = message.encoded if message.respond_to?(:encoded)
|
49
|
+
|
50
|
+
if Utilities.blank?(message)
|
51
|
+
raise ArgumentError, 'An encoded message is required to send an email'
|
52
|
+
end
|
53
|
+
|
54
|
+
message
|
55
|
+
end
|
19
56
|
end
|
20
57
|
end
|
21
58
|
end
|
@@ -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(' ')
|
@@ -75,7 +75,7 @@ module Mail
|
|
75
75
|
#
|
76
76
|
# mail.deliver!
|
77
77
|
class SMTP
|
78
|
-
|
78
|
+
attr_accessor :settings
|
79
79
|
|
80
80
|
def initialize(values)
|
81
81
|
self.settings = { :address => "localhost",
|
@@ -91,12 +91,10 @@ module Mail
|
|
91
91
|
}.merge!(values)
|
92
92
|
end
|
93
93
|
|
94
|
-
attr_accessor :settings
|
95
|
-
|
96
94
|
# Send the message via SMTP.
|
97
95
|
# The from and to attributes are optional. If not set, they are retrieve from the Message.
|
98
96
|
def deliver!(mail)
|
99
|
-
smtp_from, smtp_to, message =
|
97
|
+
smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
|
100
98
|
|
101
99
|
smtp = Net::SMTP.new(settings[:address], settings[:port])
|
102
100
|
if settings[:tls] || settings[:ssl]
|
@@ -120,7 +118,6 @@ module Mail
|
|
120
118
|
self
|
121
119
|
end
|
122
120
|
end
|
123
|
-
|
124
121
|
|
125
122
|
private
|
126
123
|
|
@@ -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
|
data/lib/mail/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.6.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikel Lindsaar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -264,12 +264,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
264
264
|
version: '0'
|
265
265
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
266
|
requirements:
|
267
|
-
- - "
|
267
|
+
- - ">"
|
268
268
|
- !ruby/object:Gem::Version
|
269
|
-
version:
|
269
|
+
version: 1.3.1
|
270
270
|
requirements: []
|
271
271
|
rubyforge_project:
|
272
|
-
rubygems_version: 2.6.
|
272
|
+
rubygems_version: 2.6.12
|
273
273
|
signing_key:
|
274
274
|
specification_version: 4
|
275
275
|
summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
|