Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7070861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:37:02+00:00 2026-05-28T05:37:02+00:00

I’m not only new to Rails, but to development in general, so I apologize

  • 0

I’m not only new to Rails, but to development in general, so I apologize if this is a basic question. I have an app where I want to send mass emails (ie newsletter) to users that opt-in. I have two concerns: (1) is my code the most efficient way to process a mass mail (ie do I need to use a for…each statement) and (2) I read other posts on Stack Overflow talking about the importance of the mail server and using delayed jobs to send email.

Other things to note:

  • I’m on Heroku
  • I was thinking about using SendGrid
  • I added delayed job code based on this tutorial

My questions are:

  1. Do most people use delayed jobs even for single recipient emails (ie a user registration confirmation)?
  2. Is my code the most efficient way to do a mass email?
  3. If, for example, there’s 1000 users. Does it make a big difference in resources (ie bandwidth, CPU, etc) if I send everyone the same email with a BCC. If so, do I just pass in a hash to the mailer (ie delete the for…each and change opt_in_user parameter to @opt_in_users) and change the recipient to bcc?

Thanks!

Controller

commmunity_users = UserCommunityRelation.find('community_id = ? and status = ?,'      current_community, "approved" )
@opt_in_users = User.find('opt_in = ?,' true)

@opt_in_users.each do |opt_in_user|
  UserMailer.send_later(:deliver_announcement, opt_in_user)
end    

UserMailer.rb

def announcement(opt_in_user)
  mail(:to => "#{opt_in_user.username} <#{opt_in_user.email}>", :subject => "Huge Announcement!")
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:37:03+00:00Added an answer on May 28, 2026 at 5:37 am

    For bulk sending, you should definitely send it via a service (We use Postbox, SendGrid is another option). In addition to the load on the servers, a service will also probably be better suited to bounces, spam blockers, etc, and it will probably offer extra benefits, such as tracking.

    Do most people use delayed jobs even for single recipient emails (ie a user registration confirmation)?

    For single user emails, I would go with direct emails in the controller.

    Is my code the most efficient way to do a mass email?

    You wouldn’t want to have a controller action manage queueing the tasks, as it will affect your sites responsiveness. Use a cron job and rake task to do it in the background.

    If, for example, there’s 1000 users. Does it make a big difference in resources (ie bandwidth, CPU, etc) if I send everyone the same email with a BCC. If so, do I just pass in a hash to the mailer (ie delete the for…each and change opt_in_user parameter to @opt_in_users) and change the recipient to bcc?

    I think BCC is fine on resource usage, but your server will be getting hit with any bounces, and it is an extra service to manage, hence, I’d go with a service as mentioned earlier

    BTW, for the #each vs for…each question, the cost of the iterator is going to be so low that it isn’t worth thinking about IMO.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.