mad_mimi_mailer 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mad_mimi_mailer.rb +21 -9
- metadata +2 -2
data/lib/mad_mimi_mailer.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require "
|
1
|
+
require "action_mailer"
|
2
2
|
require "net/http"
|
3
3
|
require "net/https"
|
4
4
|
|
5
5
|
class MadMimiMailer < ActionMailer::Base
|
6
|
-
VERSION = '0.0.
|
6
|
+
VERSION = '0.0.8'
|
7
7
|
SINGLE_SEND_URL = 'https://madmimi.com/mailer'
|
8
8
|
|
9
9
|
@@api_settings = {}
|
@@ -78,14 +78,12 @@ class MadMimiMailer < ActionMailer::Base
|
|
78
78
|
|
79
79
|
if mail.use_erb
|
80
80
|
if mail.parts.any?
|
81
|
-
|
81
|
+
params['raw_plain_text'] = content_for(mail, "text/plain")
|
82
|
+
params['raw_html'] = content_for(mail, "text/html") { |html| validate(html.body) }
|
83
|
+
else
|
84
|
+
validate(mail.body)
|
85
|
+
params['raw_html'] = mail.body
|
82
86
|
end
|
83
|
-
|
84
|
-
unless mail.body.include?("[[peek_image]]")
|
85
|
-
raise ValidationError, "You must include a web beacon in your Mimi email: [[peek_image]]"
|
86
|
-
end
|
87
|
-
|
88
|
-
params['raw_html'] = mail.body
|
89
87
|
else
|
90
88
|
params['body'] = mail.body.to_yaml
|
91
89
|
end
|
@@ -102,6 +100,20 @@ class MadMimiMailer < ActionMailer::Base
|
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
103
|
+
def content_for(mail, content_type)
|
104
|
+
part = mail.parts.detect {|p| p.content_type == content_type }
|
105
|
+
if part
|
106
|
+
yield(part) if block_given?
|
107
|
+
part.body
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def validate(content)
|
112
|
+
unless content.include?("[[peek_image]]") || content.include?("[[tracking_beacon]]")
|
113
|
+
raise ValidationError, "You must include a web beacon in your Mimi email: [[peek_image]]"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
105
117
|
def post_request
|
106
118
|
url = URI.parse(SINGLE_SEND_URL)
|
107
119
|
request = Net::HTTP::Post.new(url.path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mad_mimi_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Hoover
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-04 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|