mailgun_rails 0.5.3 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/lib/mailgun/deliverer.rb +18 -16
- data/lib/mailgun/version.rb +1 -1
- metadata +8 -7
data/MIT-LICENSE
CHANGED
data/lib/mailgun/deliverer.rb
CHANGED
@@ -16,30 +16,32 @@ module Mailgun
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def deliver!(rails_message)
|
19
|
-
|
20
|
-
remove_empty_values mailgun_message
|
21
|
-
mailgun_client.send_message mailgun_message
|
19
|
+
mailgun_client.send_message build_mailgun_message_for(rails_message)
|
22
20
|
end
|
23
21
|
|
24
22
|
private
|
25
23
|
|
26
|
-
def
|
27
|
-
mailgun_message =
|
28
|
-
|
29
|
-
|
30
|
-
prepare_mailgun_variables rails_message, mailgun_message
|
31
|
-
prepare_mailgun_recipient_variables rails_message, mailgun_message
|
24
|
+
def build_mailgun_message_for(rails_message)
|
25
|
+
mailgun_message = build_basic_mailgun_message_for rails_message
|
26
|
+
transform_mailgun_attributes_from_rails rails_message, mailgun_message
|
27
|
+
remove_empty_values mailgun_message
|
32
28
|
|
33
29
|
mailgun_message
|
34
30
|
end
|
35
31
|
|
36
|
-
def
|
37
|
-
|
32
|
+
def transform_mailgun_attributes_from_rails(rails_message, mailgun_message)
|
33
|
+
transform_reply_to rails_message, mailgun_message if rails_message.reply_to
|
34
|
+
transform_mailgun_variables rails_message, mailgun_message
|
35
|
+
transform_mailgun_recipient_variables rails_message, mailgun_message
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_basic_mailgun_message_for(rails_message)
|
39
|
+
{:from => rails_message[:from].formatted, :to => rails_message[:to].formatted, :subject => rails_message.subject,
|
38
40
|
:html => extract_html(rails_message), :text => extract_text(rails_message)}
|
39
41
|
end
|
40
42
|
|
41
|
-
def
|
42
|
-
mailgun_message['h:Reply-To'] = rails_message.reply_to
|
43
|
+
def transform_reply_to(rails_message, mailgun_message)
|
44
|
+
mailgun_message['h:Reply-To'] = rails_message.reply_to.first
|
43
45
|
end
|
44
46
|
|
45
47
|
# @see http://stackoverflow.com/questions/4868205/rails-mail-getting-the-body-as-plain-text
|
@@ -59,13 +61,13 @@ module Mailgun
|
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
|
-
def
|
64
|
+
def transform_mailgun_variables(rails_message, mailgun_message)
|
63
65
|
rails_message.mailgun_variables.try(:each) do |name, value|
|
64
66
|
mailgun_message["v:#{name}"] = value
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
def
|
70
|
+
def transform_mailgun_recipient_variables(rails_message, mailgun_message)
|
69
71
|
mailgun_message['recipient-variables'] = rails_message.mailgun_recipient_variables.to_json if rails_message.mailgun_recipient_variables
|
70
72
|
end
|
71
73
|
|
@@ -79,4 +81,4 @@ module Mailgun
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
|
-
ActionMailer::Base.add_delivery_method :mailgun, Mailgun::Deliverer
|
84
|
+
ActionMailer::Base.add_delivery_method :mailgun, Mailgun::Deliverer
|
data/lib/mailgun/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailgun_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,14 +9,14 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 3.2.13
|
22
22
|
type: :runtime
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.2.13
|
30
30
|
- !ruby/object:Gem::Dependency
|
@@ -91,7 +91,8 @@ files:
|
|
91
91
|
- Rakefile
|
92
92
|
- README.rdoc
|
93
93
|
homepage: https://github.com/jorgemanrubia/mailgun_rails/
|
94
|
-
licenses:
|
94
|
+
licenses:
|
95
|
+
- MIT
|
95
96
|
post_install_message:
|
96
97
|
rdoc_options: []
|
97
98
|
require_paths:
|
@@ -104,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
105
|
version: '0'
|
105
106
|
segments:
|
106
107
|
- 0
|
107
|
-
hash:
|
108
|
+
hash: 1001558418500426276
|
108
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
110
|
none: false
|
110
111
|
requirements:
|
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
version: '0'
|
114
115
|
segments:
|
115
116
|
- 0
|
116
|
-
hash:
|
117
|
+
hash: 1001558418500426276
|
117
118
|
requirements: []
|
118
119
|
rubyforge_project:
|
119
120
|
rubygems_version: 1.8.23
|