Q: send newsletter with delayed_job I have and admin_mailer:
class AdminMailer < ActionMailer::Base
 def send_message_to_all_users(user, subject, body, locale)
    @user = user
    @body = body
    @locale = locale
    mail(:to => user.email, :subject => subject)
  end
end

Inside my action on controller user:
def send_email_to_all_users

   users = User.all
   subject = params[:subject]
   body = params[:body]
   locale = params[:locale]
   for user in users
    User.delay(queue: "Email", priority: 20).send_message_to_all_users(user, subject, body, locale)
   end

   respond_to do |format|
    .........
   end
end

In my model User
class User
 include Mongoid::Document
 include Mongoid::Timestamps::Created
.
.
.

#delayed jobs methods
  def self.send_message_to_all_users(user, subject, body, locale)
     AdminMailer.send_message_to_all_users(user, subject, body, locale).deliver
  end

 def deliver
  sleep 15
 end

end

Mailing list of users is very long over 20.000 emails account. 
My question is if is correct this way to send newsletter with a big mailing list, or I can do this task of better way.
Thank you!

A: Look at resque_mailer, and this question

A: I think you should look into the find_in_batches method here:  http://guides.rubyonrails.org/active_record_querying.html
In your case, you could first, find all users in batches and from there, assign each batch to your send_email_to_all_users method call (replacing the User.all with each batch.
Or, even better, you can move the entire newsletter process into its own class and encapsulate it a little (thus, still calling the method from the controller but running all of the logic in the class.)
Anyway, I think find_in_batches is what you need.
