dvdplm-ar_mailer 2.0.3 → 2.0.4
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/lib/action_mailer/ar_sendmail.rb +9 -8
- metadata +3 -3
|
@@ -113,12 +113,16 @@ class Create#{table_name.classify} < ActiveRecord::Migration
|
|
|
113
113
|
t.column :mail, :text
|
|
114
114
|
t.column :last_send_attempt, :integer, :default => 0
|
|
115
115
|
t.column :last_error, :text
|
|
116
|
+
t.column :success_status, :string
|
|
116
117
|
t.column :attempts, :integer
|
|
117
118
|
t.column :failed, :boolean, :default => false
|
|
118
119
|
t.column :created_at, :datetime
|
|
119
120
|
t.column :updated_at, :datetime
|
|
120
121
|
t.column :sent_at, :datetime
|
|
121
122
|
end
|
|
123
|
+
|
|
124
|
+
add_index :emails, :sent_at
|
|
125
|
+
add_index :emails, :failed
|
|
122
126
|
end
|
|
123
127
|
|
|
124
128
|
def self.down
|
|
@@ -135,6 +139,8 @@ end
|
|
|
135
139
|
require 'active_support'
|
|
136
140
|
puts <<-EOF
|
|
137
141
|
class #{table_name.classify} < ActiveRecord::Base
|
|
142
|
+
validates_presence_of :from, :to, :mail
|
|
143
|
+
|
|
138
144
|
def sent?
|
|
139
145
|
not failed? and not sent_at.nil?
|
|
140
146
|
end
|
|
@@ -160,7 +166,7 @@ end
|
|
|
160
166
|
|
|
161
167
|
total_size = 0
|
|
162
168
|
|
|
163
|
-
puts "-Queue ID- --Size-- ----Arrival Time---- -----
|
|
169
|
+
puts "-Queue ID- --Size-- ----Arrival Time---- -----Last attempt at------ -Attempts- -Sender/Recipient--------------------------------------"
|
|
164
170
|
emails.each do |email|
|
|
165
171
|
size = email.mail.length
|
|
166
172
|
total_size += size
|
|
@@ -176,12 +182,7 @@ end
|
|
|
176
182
|
create_timestamp.strftime '%a %b %d %H:%M:%S'
|
|
177
183
|
end
|
|
178
184
|
|
|
179
|
-
puts "%10d %8d %s %s %10d %s -> %s" % [email.id, size, created, email.
|
|
180
|
-
if email.last_send_attempt > 0 then
|
|
181
|
-
puts "Last send attempt: #{Time.at email.last_send_attempt}"
|
|
182
|
-
puts "Attempt no: #{email.attempts}"
|
|
183
|
-
end
|
|
184
|
-
puts
|
|
185
|
+
puts "%10d %8d %s %s %10d %s -> %s" % [email.id, size, created, Time.at(email.last_send_attempt) || ' '*19, email.attempts, email.from, email.to]
|
|
185
186
|
end
|
|
186
187
|
|
|
187
188
|
puts "-- #{total_size/1024} Kbytes in #{emails.length} Requests."
|
|
@@ -466,6 +467,7 @@ end
|
|
|
466
467
|
res = session.send_message email.mail, email.from, email.to
|
|
467
468
|
email.failed = false
|
|
468
469
|
email.sent_at = Time.now
|
|
470
|
+
email.success_status = res.string
|
|
469
471
|
|
|
470
472
|
log "#{self.class}#deliver sent email %011d from %s to %s: %p" %
|
|
471
473
|
[email.id, email.from, email.to, res]
|
|
@@ -517,7 +519,6 @@ end
|
|
|
517
519
|
# last 300 seconds.
|
|
518
520
|
|
|
519
521
|
def find_emails
|
|
520
|
-
# options = { :conditions => ['last_send_attempt < ? AND failed = 0', Time.now.to_i - 300] }
|
|
521
522
|
options = { :conditions => {:sent_at => nil, :failed => false}}
|
|
522
523
|
options[:limit] = batch_size unless batch_size.nil?
|
|
523
524
|
mail = @email_class.find :all, options
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dvdplm-ar_mailer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Hodel
|
|
@@ -15,7 +15,7 @@ date: 2009-04-17 00:00:00 -07:00
|
|
|
15
15
|
default_executable: ar_sendmail
|
|
16
16
|
dependencies: []
|
|
17
17
|
|
|
18
|
-
description: Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.
|
|
18
|
+
description: Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail. This fork stores the email in the database for easy inspection and tracking.
|
|
19
19
|
email: adam.meehan@gmail.com
|
|
20
20
|
executables:
|
|
21
21
|
- ar_sendmail
|
|
@@ -68,7 +68,7 @@ rubyforge_project: seattlerb
|
|
|
68
68
|
rubygems_version: 1.2.0
|
|
69
69
|
signing_key:
|
|
70
70
|
specification_version: 3
|
|
71
|
-
summary: A two-phase delivery agent for ActionMailer
|
|
71
|
+
summary: A two-phase delivery agent and outbox archive for ActionMailer
|
|
72
72
|
test_files:
|
|
73
73
|
- test/test_armailer.rb
|
|
74
74
|
- test/test_arsendmail.rb
|