lib/mail_spy/manager.rb in mail_spy-0.0.17 vs lib/mail_spy/manager.rb in mail_spy-0.0.18
- old
+ new
@@ -66,11 +66,13 @@
# Must happen after the email has been saved for the id
if esp.options[:enable_sendgrid_event_tracking].present?
header = MailSpy::Sendgrid::SmtpApiHeader.new
header.setUniqueArgs({:eid => email.id.to_s})
email.headers = {'X-SMTPAPI' => header.asJSON}.merge(email.headers)
+ email.save!
end
+
email
end
# ------------------------------------------- SEND OUTSTANDING EMAILS
# Batches through all the emails that were scheduled and have come due
@@ -100,10 +102,11 @@
end
while true
emails = MailSpy::Email.
limit(step).offset(offset).asc(:_id).
- where(:schedule_at.lte => current_time, :sent => false, :failed => false).collect
+ where(:schedule_at.lte => current_time, :sent => false, :failed => false).
+ collect
break if emails.count <= 0 #returns enumerator which is never blank
emails.each do |email|
wq.enqueue_b do
begin
MailSpy::CoreMailer.template(email).deliver