mandrill-mailer-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +33 -0
- data/Appraisals +19 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +115 -0
- data/LICENSE +21 -0
- data/README.md +35 -0
- data/Rakefile +4 -0
- data/gemfiles/rails_30.gemfile +7 -0
- data/gemfiles/rails_30.gemfile.lock +122 -0
- data/gemfiles/rails_31.gemfile +7 -0
- data/gemfiles/rails_31.gemfile.lock +122 -0
- data/gemfiles/rails_32.gemfile +7 -0
- data/gemfiles/rails_32.gemfile.lock +122 -0
- data/gemfiles/rails_40.gemfile +7 -0
- data/gemfiles/rails_40.gemfile.lock +116 -0
- data/gemfiles/rails_41.gemfile +7 -0
- data/gemfiles/rails_41.gemfile.lock +116 -0
- data/lib/mandrill-mailer-rails.rb +2 -0
- data/lib/mandrill_action_mailer.rb +10 -0
- data/lib/mandrill_action_mailer/delivery_handler.rb +54 -0
- data/lib/mandrill_action_mailer/railtie.rb +12 -0
- data/mandrill-mailer-rails.gemspec +22 -0
- data/spec/integration/deliver_handler_spec.rb +166 -0
- data/spec/rails_app/.gitignore +3 -0
- data/spec/rails_app/Rakefile +6 -0
- data/spec/rails_app/app/mailers/notifier.rb +35 -0
- data/spec/rails_app/app/views/notifier/multipart.html.erb +1 -0
- data/spec/rails_app/app/views/notifier/multipart.text.erb +1 -0
- data/spec/rails_app/app/views/notifier/test.text.erb +1 -0
- data/spec/rails_app/bin/bundle +3 -0
- data/spec/rails_app/bin/rails +4 -0
- data/spec/rails_app/bin/rake +4 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +61 -0
- data/spec/rails_app/config/boot.rb +5 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/test.rb +39 -0
- data/spec/rails_app/config/initializers/assets.rb +8 -0
- data/spec/rails_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails_app/config/initializers/session_store.rb +3 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/rails_app/config/routes.rb +56 -0
- data/spec/rails_app/config/secrets.yml +14 -0
- data/spec/spec_helper.rb +30 -0
- metadata +195 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
mandrill-mailer-rails (0.0.1)
|
5
|
+
mandrill-api
|
6
|
+
rails (> 3.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.19)
|
12
|
+
actionpack (= 3.2.19)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (3.2.19)
|
15
|
+
activemodel (= 3.2.19)
|
16
|
+
activesupport (= 3.2.19)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.4)
|
20
|
+
rack (~> 1.4.5)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.2.1)
|
24
|
+
activemodel (3.2.19)
|
25
|
+
activesupport (= 3.2.19)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.19)
|
28
|
+
activemodel (= 3.2.19)
|
29
|
+
activesupport (= 3.2.19)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.19)
|
33
|
+
activemodel (= 3.2.19)
|
34
|
+
activesupport (= 3.2.19)
|
35
|
+
activesupport (3.2.19)
|
36
|
+
i18n (~> 0.6, >= 0.6.4)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
appraisal (1.0.2)
|
39
|
+
bundler
|
40
|
+
rake
|
41
|
+
thor (>= 0.14.0)
|
42
|
+
arel (3.0.3)
|
43
|
+
builder (3.0.4)
|
44
|
+
diff-lcs (1.2.5)
|
45
|
+
erubis (2.7.0)
|
46
|
+
excon (0.40.0)
|
47
|
+
hike (1.2.3)
|
48
|
+
i18n (0.6.11)
|
49
|
+
journey (1.0.4)
|
50
|
+
json (1.8.1)
|
51
|
+
mail (2.5.4)
|
52
|
+
mime-types (~> 1.16)
|
53
|
+
treetop (~> 1.4.8)
|
54
|
+
mandrill-api (1.0.52)
|
55
|
+
excon (>= 0.16.0, < 1.0)
|
56
|
+
json (>= 1.7.7, < 2.0)
|
57
|
+
mime-types (1.25.1)
|
58
|
+
multi_json (1.10.1)
|
59
|
+
polyglot (0.3.5)
|
60
|
+
rack (1.4.5)
|
61
|
+
rack-cache (1.2)
|
62
|
+
rack (>= 0.4)
|
63
|
+
rack-ssl (1.3.4)
|
64
|
+
rack
|
65
|
+
rack-test (0.6.2)
|
66
|
+
rack (>= 1.0)
|
67
|
+
rails (3.2.19)
|
68
|
+
actionmailer (= 3.2.19)
|
69
|
+
actionpack (= 3.2.19)
|
70
|
+
activerecord (= 3.2.19)
|
71
|
+
activeresource (= 3.2.19)
|
72
|
+
activesupport (= 3.2.19)
|
73
|
+
bundler (~> 1.0)
|
74
|
+
railties (= 3.2.19)
|
75
|
+
railties (3.2.19)
|
76
|
+
actionpack (= 3.2.19)
|
77
|
+
activesupport (= 3.2.19)
|
78
|
+
rack-ssl (~> 1.3.2)
|
79
|
+
rake (>= 0.8.7)
|
80
|
+
rdoc (~> 3.4)
|
81
|
+
thor (>= 0.14.6, < 2.0)
|
82
|
+
rake (10.3.2)
|
83
|
+
rdoc (3.12.2)
|
84
|
+
json (~> 1.4)
|
85
|
+
rspec-core (3.1.6)
|
86
|
+
rspec-support (~> 3.1.0)
|
87
|
+
rspec-expectations (3.1.2)
|
88
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
89
|
+
rspec-support (~> 3.1.0)
|
90
|
+
rspec-mocks (3.1.3)
|
91
|
+
rspec-support (~> 3.1.0)
|
92
|
+
rspec-rails (3.1.0)
|
93
|
+
actionpack (>= 3.0)
|
94
|
+
activesupport (>= 3.0)
|
95
|
+
railties (>= 3.0)
|
96
|
+
rspec-core (~> 3.1.0)
|
97
|
+
rspec-expectations (~> 3.1.0)
|
98
|
+
rspec-mocks (~> 3.1.0)
|
99
|
+
rspec-support (~> 3.1.0)
|
100
|
+
rspec-support (3.1.2)
|
101
|
+
sprockets (2.2.2)
|
102
|
+
hike (~> 1.2)
|
103
|
+
multi_json (~> 1.0)
|
104
|
+
rack (~> 1.0)
|
105
|
+
tilt (~> 1.1, != 1.3.0)
|
106
|
+
thor (0.19.1)
|
107
|
+
tilt (1.4.1)
|
108
|
+
treetop (1.4.15)
|
109
|
+
polyglot
|
110
|
+
polyglot (>= 0.3.1)
|
111
|
+
tzinfo (0.3.41)
|
112
|
+
|
113
|
+
PLATFORMS
|
114
|
+
ruby
|
115
|
+
|
116
|
+
DEPENDENCIES
|
117
|
+
appraisal
|
118
|
+
mandrill-mailer-rails!
|
119
|
+
rails (~> 3.2)
|
120
|
+
rake
|
121
|
+
rspec-mocks
|
122
|
+
rspec-rails
|
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
mandrill-mailer-rails (0.0.1)
|
5
|
+
mandrill-api
|
6
|
+
rails (> 3.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.1.6)
|
12
|
+
actionpack (= 4.1.6)
|
13
|
+
actionview (= 4.1.6)
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
15
|
+
actionpack (4.1.6)
|
16
|
+
actionview (= 4.1.6)
|
17
|
+
activesupport (= 4.1.6)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
actionview (4.1.6)
|
21
|
+
activesupport (= 4.1.6)
|
22
|
+
builder (~> 3.1)
|
23
|
+
erubis (~> 2.7.0)
|
24
|
+
activemodel (4.1.6)
|
25
|
+
activesupport (= 4.1.6)
|
26
|
+
builder (~> 3.1)
|
27
|
+
activerecord (4.1.6)
|
28
|
+
activemodel (= 4.1.6)
|
29
|
+
activesupport (= 4.1.6)
|
30
|
+
arel (~> 5.0.0)
|
31
|
+
activesupport (4.1.6)
|
32
|
+
i18n (~> 0.6, >= 0.6.9)
|
33
|
+
json (~> 1.7, >= 1.7.7)
|
34
|
+
minitest (~> 5.1)
|
35
|
+
thread_safe (~> 0.1)
|
36
|
+
tzinfo (~> 1.1)
|
37
|
+
appraisal (1.0.2)
|
38
|
+
bundler
|
39
|
+
rake
|
40
|
+
thor (>= 0.14.0)
|
41
|
+
arel (5.0.1.20140414130214)
|
42
|
+
builder (3.2.2)
|
43
|
+
diff-lcs (1.2.5)
|
44
|
+
erubis (2.7.0)
|
45
|
+
excon (0.40.0)
|
46
|
+
hike (1.2.3)
|
47
|
+
i18n (0.6.11)
|
48
|
+
json (1.8.1)
|
49
|
+
mail (2.6.1)
|
50
|
+
mime-types (>= 1.16, < 3)
|
51
|
+
mandrill-api (1.0.52)
|
52
|
+
excon (>= 0.16.0, < 1.0)
|
53
|
+
json (>= 1.7.7, < 2.0)
|
54
|
+
mime-types (2.4.1)
|
55
|
+
minitest (5.4.2)
|
56
|
+
multi_json (1.10.1)
|
57
|
+
rack (1.5.2)
|
58
|
+
rack-test (0.6.2)
|
59
|
+
rack (>= 1.0)
|
60
|
+
rails (4.1.6)
|
61
|
+
actionmailer (= 4.1.6)
|
62
|
+
actionpack (= 4.1.6)
|
63
|
+
actionview (= 4.1.6)
|
64
|
+
activemodel (= 4.1.6)
|
65
|
+
activerecord (= 4.1.6)
|
66
|
+
activesupport (= 4.1.6)
|
67
|
+
bundler (>= 1.3.0, < 2.0)
|
68
|
+
railties (= 4.1.6)
|
69
|
+
sprockets-rails (~> 2.0)
|
70
|
+
railties (4.1.6)
|
71
|
+
actionpack (= 4.1.6)
|
72
|
+
activesupport (= 4.1.6)
|
73
|
+
rake (>= 0.8.7)
|
74
|
+
thor (>= 0.18.1, < 2.0)
|
75
|
+
rake (10.3.2)
|
76
|
+
rspec-core (3.1.6)
|
77
|
+
rspec-support (~> 3.1.0)
|
78
|
+
rspec-expectations (3.1.2)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.1.0)
|
81
|
+
rspec-mocks (3.1.3)
|
82
|
+
rspec-support (~> 3.1.0)
|
83
|
+
rspec-rails (3.1.0)
|
84
|
+
actionpack (>= 3.0)
|
85
|
+
activesupport (>= 3.0)
|
86
|
+
railties (>= 3.0)
|
87
|
+
rspec-core (~> 3.1.0)
|
88
|
+
rspec-expectations (~> 3.1.0)
|
89
|
+
rspec-mocks (~> 3.1.0)
|
90
|
+
rspec-support (~> 3.1.0)
|
91
|
+
rspec-support (3.1.2)
|
92
|
+
sprockets (2.12.2)
|
93
|
+
hike (~> 1.2)
|
94
|
+
multi_json (~> 1.0)
|
95
|
+
rack (~> 1.0)
|
96
|
+
tilt (~> 1.1, != 1.3.0)
|
97
|
+
sprockets-rails (2.1.4)
|
98
|
+
actionpack (>= 3.0)
|
99
|
+
activesupport (>= 3.0)
|
100
|
+
sprockets (~> 2.8)
|
101
|
+
thor (0.19.1)
|
102
|
+
thread_safe (0.3.4)
|
103
|
+
tilt (1.4.1)
|
104
|
+
tzinfo (1.2.2)
|
105
|
+
thread_safe (~> 0.1)
|
106
|
+
|
107
|
+
PLATFORMS
|
108
|
+
ruby
|
109
|
+
|
110
|
+
DEPENDENCIES
|
111
|
+
appraisal
|
112
|
+
mandrill-mailer-rails!
|
113
|
+
rails (~> 4.0)
|
114
|
+
rake
|
115
|
+
rspec-mocks
|
116
|
+
rspec-rails
|
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
mandrill-mailer-rails (0.0.1)
|
5
|
+
mandrill-api
|
6
|
+
rails (> 3.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.1.6)
|
12
|
+
actionpack (= 4.1.6)
|
13
|
+
actionview (= 4.1.6)
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
15
|
+
actionpack (4.1.6)
|
16
|
+
actionview (= 4.1.6)
|
17
|
+
activesupport (= 4.1.6)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
actionview (4.1.6)
|
21
|
+
activesupport (= 4.1.6)
|
22
|
+
builder (~> 3.1)
|
23
|
+
erubis (~> 2.7.0)
|
24
|
+
activemodel (4.1.6)
|
25
|
+
activesupport (= 4.1.6)
|
26
|
+
builder (~> 3.1)
|
27
|
+
activerecord (4.1.6)
|
28
|
+
activemodel (= 4.1.6)
|
29
|
+
activesupport (= 4.1.6)
|
30
|
+
arel (~> 5.0.0)
|
31
|
+
activesupport (4.1.6)
|
32
|
+
i18n (~> 0.6, >= 0.6.9)
|
33
|
+
json (~> 1.7, >= 1.7.7)
|
34
|
+
minitest (~> 5.1)
|
35
|
+
thread_safe (~> 0.1)
|
36
|
+
tzinfo (~> 1.1)
|
37
|
+
appraisal (1.0.2)
|
38
|
+
bundler
|
39
|
+
rake
|
40
|
+
thor (>= 0.14.0)
|
41
|
+
arel (5.0.1.20140414130214)
|
42
|
+
builder (3.2.2)
|
43
|
+
diff-lcs (1.2.5)
|
44
|
+
erubis (2.7.0)
|
45
|
+
excon (0.40.0)
|
46
|
+
hike (1.2.3)
|
47
|
+
i18n (0.6.11)
|
48
|
+
json (1.8.1)
|
49
|
+
mail (2.6.1)
|
50
|
+
mime-types (>= 1.16, < 3)
|
51
|
+
mandrill-api (1.0.52)
|
52
|
+
excon (>= 0.16.0, < 1.0)
|
53
|
+
json (>= 1.7.7, < 2.0)
|
54
|
+
mime-types (2.4.1)
|
55
|
+
minitest (5.4.2)
|
56
|
+
multi_json (1.10.1)
|
57
|
+
rack (1.5.2)
|
58
|
+
rack-test (0.6.2)
|
59
|
+
rack (>= 1.0)
|
60
|
+
rails (4.1.6)
|
61
|
+
actionmailer (= 4.1.6)
|
62
|
+
actionpack (= 4.1.6)
|
63
|
+
actionview (= 4.1.6)
|
64
|
+
activemodel (= 4.1.6)
|
65
|
+
activerecord (= 4.1.6)
|
66
|
+
activesupport (= 4.1.6)
|
67
|
+
bundler (>= 1.3.0, < 2.0)
|
68
|
+
railties (= 4.1.6)
|
69
|
+
sprockets-rails (~> 2.0)
|
70
|
+
railties (4.1.6)
|
71
|
+
actionpack (= 4.1.6)
|
72
|
+
activesupport (= 4.1.6)
|
73
|
+
rake (>= 0.8.7)
|
74
|
+
thor (>= 0.18.1, < 2.0)
|
75
|
+
rake (10.3.2)
|
76
|
+
rspec-core (3.1.6)
|
77
|
+
rspec-support (~> 3.1.0)
|
78
|
+
rspec-expectations (3.1.2)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.1.0)
|
81
|
+
rspec-mocks (3.1.3)
|
82
|
+
rspec-support (~> 3.1.0)
|
83
|
+
rspec-rails (3.1.0)
|
84
|
+
actionpack (>= 3.0)
|
85
|
+
activesupport (>= 3.0)
|
86
|
+
railties (>= 3.0)
|
87
|
+
rspec-core (~> 3.1.0)
|
88
|
+
rspec-expectations (~> 3.1.0)
|
89
|
+
rspec-mocks (~> 3.1.0)
|
90
|
+
rspec-support (~> 3.1.0)
|
91
|
+
rspec-support (3.1.2)
|
92
|
+
sprockets (2.12.2)
|
93
|
+
hike (~> 1.2)
|
94
|
+
multi_json (~> 1.0)
|
95
|
+
rack (~> 1.0)
|
96
|
+
tilt (~> 1.1, != 1.3.0)
|
97
|
+
sprockets-rails (2.1.4)
|
98
|
+
actionpack (>= 3.0)
|
99
|
+
activesupport (>= 3.0)
|
100
|
+
sprockets (~> 2.8)
|
101
|
+
thor (0.19.1)
|
102
|
+
thread_safe (0.3.4)
|
103
|
+
tilt (1.4.1)
|
104
|
+
tzinfo (1.2.2)
|
105
|
+
thread_safe (~> 0.1)
|
106
|
+
|
107
|
+
PLATFORMS
|
108
|
+
ruby
|
109
|
+
|
110
|
+
DEPENDENCIES
|
111
|
+
appraisal
|
112
|
+
mandrill-mailer-rails!
|
113
|
+
rails (~> 4.1)
|
114
|
+
rake
|
115
|
+
rspec-mocks
|
116
|
+
rspec-rails
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module MandrillActionMailer
|
2
|
+
class DeliveryHandler
|
3
|
+
attr_accessor :settings
|
4
|
+
|
5
|
+
MIME_TYPES = {
|
6
|
+
:html => "text/html",
|
7
|
+
:text => "text/plain"
|
8
|
+
}.freeze
|
9
|
+
|
10
|
+
def initialize(options={})
|
11
|
+
self.settings = { :track_opens => MandrillActionMailer.config.track_opens, :track_clicks => MandrillActionMailer.config.track_clicks }.merge(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def deliver!(message)
|
15
|
+
message_payload = {
|
16
|
+
:track_opens => settings[:track_opens],
|
17
|
+
:track_clicks => settings[:track_clicks],
|
18
|
+
:subject => message.subject,
|
19
|
+
:from_email => message.from.first,
|
20
|
+
:to => message.to.map { |email| { :email => email, :name => email } },
|
21
|
+
}
|
22
|
+
|
23
|
+
if !(message[:from_name].nil? || message[:from_name].value.blank?)
|
24
|
+
message_payload[:from_name] = message[:from_name].value
|
25
|
+
end
|
26
|
+
|
27
|
+
if !message.reply_to.blank?
|
28
|
+
message_payload[:headers] ||= {}
|
29
|
+
message_payload[:headers]['Reply-To'] = message.reply_to.first
|
30
|
+
end
|
31
|
+
|
32
|
+
if !message.bcc.blank?
|
33
|
+
message_payload[:bcc_address] = message.bcc.first
|
34
|
+
end
|
35
|
+
|
36
|
+
MIME_TYPES.keys.each do |format|
|
37
|
+
content = content_for(message, format)
|
38
|
+
message_payload[format] = content.to_s unless content.blank?
|
39
|
+
end
|
40
|
+
|
41
|
+
MandrillActionMailer.client.messages.send(message_payload)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def content_for(message, format)
|
47
|
+
content = message.send(:"#{format.to_s}_part")
|
48
|
+
content = content.body if content && content.respond_to?(:body)
|
49
|
+
|
50
|
+
content ||= message.body if message.mime_type == MIME_TYPES.fetch(format)
|
51
|
+
content
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|