postmail_ruby 0.1.2 → 0.1.4
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/README.md +1 -1
- data/lib/postmail_ruby/delivery_method/http.rb +9 -9
- data/lib/postmail_ruby/delivery_method/smtp.rb +1 -1
- data/lib/postmail_ruby/railtie.rb +1 -1
- data/lib/postmail_ruby/version.rb +1 -1
- data/lib/postmail_ruby.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c5fa264c1d733166a1db09939c27525d767dc296503fb832d75791a968af57e
|
4
|
+
data.tar.gz: 01ac234e3745cfc52f728247ea6bfca7c5379a2ff80894a23db8a6d405fd28ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f90ef2298e2d2d16869299d5ee6adc03b5557482eced9626fd4b7e41cba5cf95621070bc5dddf9312af4996c500ee947237ba6a47ea46e83e8f38db2711ba8
|
7
|
+
data.tar.gz: f4831553a8df684a43346026b565cf1e3cb63e33be7533c68a773f88a83fc8747812684abe71314415495172e796e8e80f70d1793f8d043cc6071980924242fc
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ module PostmailRuby
|
|
18
18
|
# Initialize the HTTP delivery method. Accepts a hash of
|
19
19
|
# options that may override configuration defaults. Options
|
20
20
|
# are stored but not used directly; configuration is read
|
21
|
-
# from
|
21
|
+
# from PostmailRuby.config for each delivery to ensure the most
|
22
22
|
# current environment variables are respected.
|
23
23
|
#
|
24
24
|
# @param [Hash] options delivery options (currently unused)
|
@@ -34,7 +34,7 @@ module PostmailRuby
|
|
34
34
|
#
|
35
35
|
# @param [Mail::Message] mail the message to send
|
36
36
|
def deliver!(mail)
|
37
|
-
config =
|
37
|
+
config = PostmailRuby.config
|
38
38
|
uri = URI.parse(config.api_endpoint)
|
39
39
|
|
40
40
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -94,16 +94,16 @@ module PostmailRuby
|
|
94
94
|
Array(value).join(',')
|
95
95
|
end
|
96
96
|
|
97
|
-
# Extract a specific MIME part "../../
|
98
|
-
# multipart messages, the first matching part "../../
|
97
|
+
# Extract a specific MIME part "../../postmail_ruby/delivery_method""."from the message. For
|
98
|
+
# multipart messages, the first matching part "../../postmail_ruby/delivery_method""."is returned.
|
99
99
|
# For non-multipart, the body is returned if the MIME type
|
100
|
-
# matches. Returns nil if no matching part "../../
|
101
|
-
def extract_part(mail,
|
100
|
+
# matches. Returns nil if no matching part "../../postmail_ruby/delivery_method""."exists.
|
101
|
+
def extract_part(mail, mime_type_prefix)
|
102
102
|
if mail.multipart?
|
103
|
-
mail.parts.find { |p| p.mime_type&.start_with?(
|
104
|
-
part
|
103
|
+
part = mail.parts.find { |p| p.mime_type&.start_with?(mime_type_prefix) }
|
104
|
+
part&.body&.decoded
|
105
105
|
else
|
106
|
-
mail.mime_type&.start_with?(
|
106
|
+
mail.mime_type&.start_with?(mime_type_prefix) ? mail.body&.decoded : nil
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -28,7 +28,7 @@ module PostmailRuby
|
|
28
28
|
#
|
29
29
|
# @param [Mail::Message] mail the message to send
|
30
30
|
def deliver!(mail)
|
31
|
-
config_settings =
|
31
|
+
config_settings = PostmailRuby.config.smtp_settings
|
32
32
|
smtp_settings = config_settings.merge(settings)
|
33
33
|
smtp = ::Mail::SMTP.new(smtp_settings)
|
34
34
|
smtp.deliver!(mail)
|
@@ -17,7 +17,7 @@ module PostmailRuby
|
|
17
17
|
ActionMailer::Base.add_delivery_method :postmail_api, PostmailRuby::DeliveryMethod::HTTP
|
18
18
|
|
19
19
|
# Determine which delivery method to use based on configuration
|
20
|
-
delivery_method =
|
20
|
+
delivery_method = PostmailRuby.config.delivery_method
|
21
21
|
ActionMailer::Base.delivery_method = case delivery_method
|
22
22
|
when :api
|
23
23
|
:postmail_api
|
data/lib/postmail_ruby.rb
CHANGED
@@ -12,7 +12,7 @@ module PostmailRuby
|
|
12
12
|
class << self
|
13
13
|
# Accessor for the configuration instance. When first called
|
14
14
|
# a new Configuration object is created and memoized. This
|
15
|
-
# object reads environment variables to determine how
|
15
|
+
# object reads environment variables to determine how PostmailRuby
|
16
16
|
# should behave (API vs SMTP, credentials, endpoints, etc.).
|
17
17
|
#
|
18
18
|
# @return [PostmailRuby::Configuration]
|