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 6658815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:57:26+00:00 2026-05-26T01:57:26+00:00

In my app, when a user signs up, they are sent a confirmation email.

  • 0

In my app, when a user signs up, they are sent a confirmation email. I use delayed_job, to make the process of sending email go in background.

But disadvantage of using delayed_job is having a worker all the time. And having a worker for this is expensive.

Is there something other than delayed_job, that will make email sending go in background.

Here is my controller code snippet.

def create
    @user = User.new(params[:user])

    respond_to do |format|
      if @user.save
        UserMailer.delay.registration_confirmation(@user)
        format.html { redirect_to @user, notice: 'User was successfully created.' }
        format.js

The point is I am having 20-40 signups in a day. That means at most the the queue is busy for about 60 seconds and I will have to pay for the the entire day, which is very impractical. Some other nice approach.

  • 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-26T01:57:27+00:00Added an answer on May 26, 2026 at 1:57 am

    I recommend setting up a cron that will run once every hour and send out e-mails. You’ll have to create a new model, QueuedEmail or something similar, and then instead of using ActionMailer right away, save it as a QueuedEmail. This is basically the same thing that delayed_job does, but you’ll have more control over when it gets run, and crons don’t take up much memory.

    The cron should be to script/rails runner, and you should have a method in your QueuedEmail model that will send out all pending e-mails. I recommend whenever to generate crontabs (quick to setup and very easy to use). The cron will look something like this (this example is set to run once a day at 2am, you can look up how to adjust the intervals, I don’t know off the top of my head):

    0 2 * * * /bin/bash -l -c 'cd /RAILS_ROOT/ && script/rails runner -e production '\''QueuedEmail.send_pending'\'' >> log/cron.log 2>&1'
    

    Or in Whenever:

    every :day, :at => '2 am' do
        runner "QueuedEmail.send_pending"
    end
    

    QueuedEmail#send_pending

    class QueuedEmail < ActiveRecord::Base
        def send_pending
            all.each do |email|
                params = your_parsing_method(email.params)
                record = your_parsing_method(email.record)
                email.destroy if UserMailer.registration_confirmation(record, params).deliver
            end
        end
    end
    

    UserController#create

    if @user = User.create(params[:user])
        User.delay_email(@user, params[:user])
        redirect_to user_path(@user), :notice => "Created User. E-mail will be sent within the hour."
    end
    

    User#delay_email

    def delay_email(record, params)
        QueuedEmail.create(:record => your_db_formatting_method(record), :params => your_db_formatting_method(params.to_s)) # or use something built in, like to_s.
    end
    

    None of this code is tested and is probably quite broken, but it’s the general idea that matters. You could also go one step further and extend the Rails ActionMailer, but that is far more advanced.

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

Sidebar

Related Questions

My app is set up so that if a user signs in with Oauth
user signs up for a key and secret from my site, then they can
I have a team registration app. A user signs up to be a part
I want a simple sign in app in which a user logins successfully if
In my app,user can select image from gallery and after that he can zoom
Am developing an iPhone app. From my app user can to follow my twitter
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
Context: multi-user app (node.js) - 1 painter, n clients Canvas size: 650x400 px (=
On my app a user may or may not have a profile. An example
in a J2EE app if user explicitly takes out the the ending page name

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.