iron_mailer 0.0.8 → 0.0.9
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.
- data/.gitignore +1 -0
- data/lib/iron_mailer/send_email.rb +15 -34
- data/lib/iron_mailer/version.rb +1 -1
- data/spec/iron_mailer/send_email_spec.rb +16 -6
- metadata +1 -2
- data/payload.json +0 -23
data/.gitignore
CHANGED
@@ -24,43 +24,24 @@ class IronMailer::SendEmail
|
|
24
24
|
@delivery_method_settings={}
|
25
25
|
end
|
26
26
|
|
27
|
-
# Mail.defaults do
|
28
|
-
# if options['delivery_method'].is_a?(Hash)
|
29
|
-
# delivery_method_hash = options['delivery_method']
|
30
|
-
# params = delivery_method_hash.values.first.clone
|
31
|
-
# params.keys.each do |key|
|
32
|
-
# params[(key.to_sym rescue key) || key] = params.delete(key)
|
33
|
-
# end
|
34
|
-
# delivery_method delivery_method_hash.keys.first.to_sym, params
|
35
|
-
# else
|
36
|
-
# delivery_method options['delivery_method'].to_sym
|
37
|
-
# end
|
38
|
-
# end
|
39
27
|
end
|
40
28
|
|
41
29
|
def split_email(source_email)
|
42
30
|
tos = source_email.to
|
43
31
|
tos.uniq.map{|destination|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
body source_email.html_part.body.to_s
|
58
|
-
end if source_email.html_part
|
59
|
-
|
60
|
-
text_part do
|
61
|
-
body source_email.text_part.body.to_s
|
62
|
-
end if source_email.text_part
|
63
|
-
end
|
32
|
+
duplicate = source_email.clone
|
33
|
+
duplicate.to = destination
|
34
|
+
|
35
|
+
if destination==tos.first
|
36
|
+
duplicate.message_id=source_email.message_id
|
37
|
+
duplicate.bcc=source_email.bcc
|
38
|
+
duplicate.cc=source_email.cc
|
39
|
+
else
|
40
|
+
duplicate.message_id = nil
|
41
|
+
duplicate.bcc = nil
|
42
|
+
duplicate.cc = nil
|
43
|
+
end
|
44
|
+
duplicate
|
64
45
|
}
|
65
46
|
end
|
66
47
|
|
@@ -69,7 +50,7 @@ class IronMailer::SendEmail
|
|
69
50
|
'date'=>mail.date,
|
70
51
|
'from'=>mail.from,
|
71
52
|
'to'=>mail.to,
|
72
|
-
'
|
53
|
+
'body'=>mail.body.to_s
|
73
54
|
}
|
74
55
|
end
|
75
56
|
|
@@ -81,8 +62,8 @@ class IronMailer::SendEmail
|
|
81
62
|
begin
|
82
63
|
source_email = Mail.new(message.body)
|
83
64
|
puts "Processing: #{source_email.subject}" if self.debug
|
65
|
+
puts self.delivery_method=>self.delivery_method_settings if self.debug
|
84
66
|
mails = self.split_email(source_email)
|
85
|
-
|
86
67
|
mails.each do |mail|
|
87
68
|
mail.delivery_method self.delivery_method, self.delivery_method_settings
|
88
69
|
mail.deliver
|
data/lib/iron_mailer/version.rb
CHANGED
@@ -107,12 +107,16 @@ describe IronMailer::SendEmail do
|
|
107
107
|
to to
|
108
108
|
from "from@example.com"
|
109
109
|
subject "This is a test email"
|
110
|
-
|
111
|
-
body
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
110
|
+
if block_given?
|
111
|
+
body yield
|
112
|
+
else
|
113
|
+
text_part do
|
114
|
+
body "This is a test"
|
115
|
+
end
|
116
|
+
html_part do
|
117
|
+
content_type 'text/html; charset=UTF-8'
|
118
|
+
body "<h1>This is a test</h1>"
|
119
|
+
end
|
116
120
|
end
|
117
121
|
end
|
118
122
|
end
|
@@ -260,5 +264,11 @@ describe IronMailer::SendEmail do
|
|
260
264
|
@send_email.split_email(@test_email).first.cc.should == @test_email.cc
|
261
265
|
end
|
262
266
|
|
267
|
+
it "should handle non-multipart emails" do
|
268
|
+
@test_email=test_email{
|
269
|
+
"This is not multipart"
|
270
|
+
}
|
271
|
+
@send_email.split_email(@test_email).first.body.to_s.should =~ /This is not multipart/
|
272
|
+
end
|
263
273
|
end
|
264
274
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -141,7 +141,6 @@ files:
|
|
141
141
|
- lib/iron_mailer/mq_mailer.rb
|
142
142
|
- lib/iron_mailer/send_email.rb
|
143
143
|
- lib/iron_mailer/version.rb
|
144
|
-
- payload.json
|
145
144
|
- spec/iron_mailer/mq_mailer_spec.rb
|
146
145
|
- spec/iron_mailer/send_email_spec.rb
|
147
146
|
homepage: ''
|
data/payload.json
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"debug": "true",
|
3
|
-
"delivery_method": {
|
4
|
-
"smtp": {
|
5
|
-
"address": "smtp.sendgrid.net",
|
6
|
-
"authentication": "plain",
|
7
|
-
"domain": "teamdriveaway.com",
|
8
|
-
"password": "trucking2006",
|
9
|
-
"port": 587,
|
10
|
-
"user_name": "teamdriveaway"
|
11
|
-
}
|
12
|
-
},
|
13
|
-
"iron_cache": {
|
14
|
-
"cache_name": "development_email_cache",
|
15
|
-
"project_id": "50a79df0a6498073e700560c",
|
16
|
-
"token": "6P0Hr8umXZruKzS3SbKF1vuu1E8"
|
17
|
-
},
|
18
|
-
"iron_mq": {
|
19
|
-
"project_id": "511fb1f0d429792c50001158",
|
20
|
-
"queue_name": "development_mail_queue",
|
21
|
-
"token": "xv0iMDhbPB2xN5EaDH8CK4jAdQs"
|
22
|
-
}
|
23
|
-
}
|