mta-settings 1.0.0 → 1.1.0
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 +5 -5
- data/README.markdown +1 -0
- data/lib/mta_settings.rb +16 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9941d965cb662d17e4ccc6aaba278188fa3dce01586729c02e8ab3a27f3488a9
|
4
|
+
data.tar.gz: ecb685af8ac3f93c19a62bf3358d6bf2f278fb52a6f8e212f00c6baf9016c9ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 392e7d22cf17a91cb3458072000a5bc65e9bb15280c94ef617c70bafd11f11b597759d1fdfac5138fb167167d1aee1c85194463961f2bf77084d45a2bcfe3bc3
|
7
|
+
data.tar.gz: deaad6591eaf035ab06ed337f8657d1f9cd3c72a9dcf17fcdc029ff7756f52117c422b40c57b9a5fc605cccbb0f1dc0684756e60fe9e61ad283942dca44787ea
|
data/README.markdown
CHANGED
@@ -40,6 +40,7 @@ variables, in order of decreasing precedence:
|
|
40
40
|
* `MANDRILL_APIKEY`: Mandrill
|
41
41
|
* `POSTMARK_API_TOKEN`: Postmark
|
42
42
|
* `MAILGUN_SMTP_LOGIN`: Mailgun
|
43
|
+
* `MAILTRAP_API_TOKEN`: Mailtrap (for development)
|
43
44
|
|
44
45
|
If no supported environment variable is found, the configuration is left
|
45
46
|
blank. This enables easy defaulting:
|
data/lib/mta_settings.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'cgi'
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
3
5
|
require 'active_support/core_ext/object/blank'
|
4
6
|
require 'active_support/lazy_load_hooks'
|
5
7
|
|
@@ -107,6 +109,17 @@ module MtaSettings
|
|
107
109
|
:password => env['MAILGUN_SMTP_PASSWORD'],
|
108
110
|
:domain => domain,
|
109
111
|
}]
|
112
|
+
elsif env['MAILTRAP_API_TOKEN'].present?
|
113
|
+
response = Net::HTTP.get(URI.parse("https://mailtrap.io/api/v1/inboxes.json?api_token=#{env['MAILTRAP_API_TOKEN']}"))
|
114
|
+
first_inbox = JSON.parse(response)[0]
|
115
|
+
[:smtp, {
|
116
|
+
:address => first_inbox['domain'],
|
117
|
+
:port => first_inbox['smtp_ports'][0],
|
118
|
+
:authentication => :plain,
|
119
|
+
:user_name => first_inbox['username'],
|
120
|
+
:password => first_inbox['password'],
|
121
|
+
:domain => first_inbox['domain']
|
122
|
+
}]
|
110
123
|
end
|
111
124
|
end
|
112
125
|
|
@@ -139,13 +152,13 @@ module MtaSettings
|
|
139
152
|
class_attribute(accessor) unless respond_to?(accessor)
|
140
153
|
send(:"#{accessor}=", settings)
|
141
154
|
if settings[:from]
|
142
|
-
default from
|
155
|
+
default :from => settings[:from]
|
143
156
|
elsif !default.has_key?(:from) &&
|
144
157
|
![nil, LOCALHOST].include?(settings[:domain])
|
145
|
-
default from
|
158
|
+
default :from => "noreply@#{settings[:domain]}"
|
146
159
|
elsif !default.has_key?(:from) &&
|
147
160
|
settings[:user_name] =~ /\A\S+@\S+\.\w+\z/
|
148
|
-
default from
|
161
|
+
default :from => settings[:user_name]
|
149
162
|
end
|
150
163
|
end
|
151
164
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mta-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pope
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.7.3
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Configure ActionMailer or Mail delivery settings based on the environment
|