# setts all products to check or not their quantity
class SendNewsletterJob < ApplicationJob
  queue_as :default

  def perform
    emails = Email.where('sended = 0')
    emails.each do |em|
      NewsletterMailer.news_mail(em.email).deliver
      em.sended = true
      em.save
      sleep(2)
    end
  end
end
