iron_mailer 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'iron_cache'
|
2
2
|
class IronMailer::SendEmail
|
3
|
-
attr_reader :iron_mq_client, :iron_cache_client, :queue, :cache
|
3
|
+
attr_reader :iron_mq_client, :iron_cache_client, :queue, :cache, :debug
|
4
4
|
|
5
5
|
def initialize(options={})
|
6
6
|
@iron_mq_client = IronMQ::Client.new(options['iron_mq'])
|
@@ -8,7 +8,7 @@ class IronMailer::SendEmail
|
|
8
8
|
@iron_cache_client = IronCache::Client.new(options['iron_cache'])
|
9
9
|
|
10
10
|
@cache = @iron_cache_client.cache(options['iron_cache']['cache_name'])
|
11
|
-
|
11
|
+
@debug = options['debug']
|
12
12
|
Mail.defaults do
|
13
13
|
if options['delivery_method'].is_a?(Hash)
|
14
14
|
delivery_method_hash = options['delivery_method']
|
@@ -61,7 +61,7 @@ class IronMailer::SendEmail
|
|
61
61
|
messages.each do |message|
|
62
62
|
begin
|
63
63
|
source_email = Mail.new(message.body)
|
64
|
-
|
64
|
+
puts "Processing: #{source_email.subject}" if self.debug
|
65
65
|
mails = self.split_email(source_email)
|
66
66
|
|
67
67
|
mails.each do |mail|
|
@@ -71,10 +71,15 @@ class IronMailer::SendEmail
|
|
71
71
|
end
|
72
72
|
message.delete
|
73
73
|
rescue Exception=>e
|
74
|
+
if self.debug
|
75
|
+
puts e.message
|
76
|
+
puts e.backtrace
|
77
|
+
end
|
74
78
|
errors << message
|
75
79
|
end
|
76
80
|
end
|
77
81
|
errors.each do |message|
|
82
|
+
puts "Releasing: #{message.id}" if self.debug
|
78
83
|
message.release
|
79
84
|
end
|
80
85
|
|
data/lib/iron_mailer/version.rb
CHANGED
@@ -92,7 +92,7 @@ describe IronMailer::SendEmail do
|
|
92
92
|
def test_config
|
93
93
|
@iron_mq_config = JSON.parse(File.read('spec/config/iron_mq.json'))
|
94
94
|
@iron_cache_config = JSON.parse(File.read('spec/config/iron_cache.json'))
|
95
|
-
{'iron_mq'=>@iron_mq_config, 'iron_cache'=>@iron_cache_config.merge('cache_name'=>"test_email_cache"), 'delivery_method'=>'test'}
|
95
|
+
{'iron_mq'=>@iron_mq_config, 'iron_cache'=>@iron_cache_config.merge('cache_name'=>"test_email_cache"), 'delivery_method'=>'test', 'debug'=>true}
|
96
96
|
end
|
97
97
|
|
98
98
|
def test_email(other_tos=[])
|