mailgun_rails 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailgun_rails.rb +2 -2
- data/lib/{mailgun → mailgun_rails}/attachment.rb +1 -1
- data/lib/mailgun_rails/client.rb +31 -0
- data/lib/{mailgun → mailgun_rails}/deliverer.rb +12 -6
- data/lib/{mailgun → mailgun_rails}/mail_ext.rb +0 -0
- data/lib/mailgun_rails/version.rb +3 -0
- metadata +8 -8
- data/lib/mailgun/client.rb +0 -25
- data/lib/mailgun/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63183189eacb0c20e4a14087e07e86e9b4624d01
|
4
|
+
data.tar.gz: f7f9035897ab07b44cd3b918212b148d943bab45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2815255a0acc510d7c3a23d9c03e9ab7a9a71ef7ed38ea48f28706bd74ec04da66b3ed8a4d4e3104b20b2d667e76a85729cc11e4a090e5be1c29057d87afa66
|
7
|
+
data.tar.gz: e97e56b7f3ab995a704192dd87c541151491c8ab1d6abcca2d192a796d4636867199d93cfcd7c5d5ec28db244124526023fcaf86b99873c234c5acd8af9aeab8
|
data/lib/mailgun_rails.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
|
3
|
+
|
4
|
+
module MailgunRails
|
5
|
+
class Client
|
6
|
+
attr_reader :api_key, :domain, :verify_ssl
|
7
|
+
|
8
|
+
def initialize(api_key, domain, verify_ssl = true)
|
9
|
+
@api_key = api_key
|
10
|
+
@domain = domain
|
11
|
+
@verify_ssl = verify_ssl
|
12
|
+
end
|
13
|
+
|
14
|
+
def send_message(options)
|
15
|
+
RestClient::Request.execute(
|
16
|
+
method: :post,
|
17
|
+
url: mailgun_url,
|
18
|
+
payload: options,
|
19
|
+
verify_ssl: verify_ssl
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def mailgun_url
|
24
|
+
api_url+"/messages"
|
25
|
+
end
|
26
|
+
|
27
|
+
def api_url
|
28
|
+
"https://api:#{api_key}@api.mailgun.net/v3/#{domain}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module MailgunRails
|
2
2
|
class Deliverer
|
3
3
|
|
4
4
|
attr_accessor :settings
|
@@ -15,6 +15,11 @@ module Mailgun
|
|
15
15
|
self.settings[:api_key]
|
16
16
|
end
|
17
17
|
|
18
|
+
def verify_ssl
|
19
|
+
#default value = true
|
20
|
+
self.settings[:verify_ssl] != false
|
21
|
+
end
|
22
|
+
|
18
23
|
def deliver!(rails_message)
|
19
24
|
response = mailgun_client.send_message build_mailgun_message_for(rails_message)
|
20
25
|
if response.code == 200
|
@@ -63,9 +68,9 @@ module Mailgun
|
|
63
68
|
rails_message.attachments.each do |attachment|
|
64
69
|
# then add as a file object
|
65
70
|
if attachment.inline?
|
66
|
-
mailgun_message[:inline] <<
|
71
|
+
mailgun_message[:inline] << MailgunRails::Attachment.new(attachment, encoding: 'ascii-8bit', inline: true)
|
67
72
|
else
|
68
|
-
mailgun_message[:attachment] <<
|
73
|
+
mailgun_message[:attachment] << MailgunRails::Attachment.new(attachment, encoding: 'ascii-8bit')
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
@@ -116,13 +121,14 @@ module Mailgun
|
|
116
121
|
end
|
117
122
|
|
118
123
|
def remove_empty_values(mailgun_message)
|
119
|
-
mailgun_message.delete_if { |key, value| value.nil?
|
124
|
+
mailgun_message.delete_if { |key, value| value.nil? or
|
125
|
+
value.respond_to?(:empty?) && value.empty? }
|
120
126
|
end
|
121
127
|
|
122
128
|
def mailgun_client
|
123
|
-
@
|
129
|
+
@maingun_client ||= Client.new(api_key, domain, verify_ssl)
|
124
130
|
end
|
125
131
|
end
|
126
132
|
end
|
127
133
|
|
128
|
-
ActionMailer::Base.add_delivery_method :mailgun,
|
134
|
+
ActionMailer::Base.add_delivery_method :mailgun, MailgunRails::Deliverer
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailgun_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Manrubia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -90,12 +90,12 @@ files:
|
|
90
90
|
- MIT-LICENSE
|
91
91
|
- README.rdoc
|
92
92
|
- Rakefile
|
93
|
-
- lib/mailgun/attachment.rb
|
94
|
-
- lib/mailgun/client.rb
|
95
|
-
- lib/mailgun/deliverer.rb
|
96
|
-
- lib/mailgun/mail_ext.rb
|
97
|
-
- lib/mailgun/version.rb
|
98
93
|
- lib/mailgun_rails.rb
|
94
|
+
- lib/mailgun_rails/attachment.rb
|
95
|
+
- lib/mailgun_rails/client.rb
|
96
|
+
- lib/mailgun_rails/deliverer.rb
|
97
|
+
- lib/mailgun_rails/mail_ext.rb
|
98
|
+
- lib/mailgun_rails/version.rb
|
99
99
|
homepage: https://github.com/jorgemanrubia/mailgun_rails/
|
100
100
|
licenses:
|
101
101
|
- MIT
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.5.1
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Rails Action Mailer adapter for Mailgun
|
data/lib/mailgun/client.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'rest_client'
|
2
|
-
|
3
|
-
|
4
|
-
module Mailgun
|
5
|
-
class Client
|
6
|
-
attr_reader :api_key, :domain
|
7
|
-
|
8
|
-
def initialize(api_key, domain)
|
9
|
-
@api_key = api_key
|
10
|
-
@domain = domain
|
11
|
-
end
|
12
|
-
|
13
|
-
def send_message(options)
|
14
|
-
RestClient.post mailgun_url, options
|
15
|
-
end
|
16
|
-
|
17
|
-
def mailgun_url
|
18
|
-
api_url+"/messages"
|
19
|
-
end
|
20
|
-
|
21
|
-
def api_url
|
22
|
-
"https://api:#{api_key}@api.mailgun.net/v3/#{domain}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/mailgun/version.rb
DELETED