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

  • Home
  • SEARCH
  • 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 8133791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:44:59+00:00 2026-06-06T09:44:59+00:00

Possible Duplicate: how to keep sending emails to users every week depending on user

  • 0

Possible Duplicate:
how to keep sending emails to users every week depending on user date input in rails

I am building a system that allows a user to insert info name, date, and email. I want the system to automatically send emails to its users every 7 days from which they inserted.

here`s my mailer

class UserMailer < ActionMailer::Base
  default from: "from@example.com"
   def welcome_email(dop)
    @dop = dop
    @url  = "http://example.com/login"
    mail(:to => dop.mail, :subject => "Welcome to My Awesome Site")
  end
end

and this is controller:

def create
    @dop = Dop.new(params[:dop])

    respond_to do |format|
      if @dop.save
        UserMailer.welcome_email(@dop).deliver
        format.html { redirect_to @dop, notice: 'Dop was successfully created.' }
        format.json { render json: @dop, status: :created, location: @dop }
      else
        format.html { render action: "new" }
        format.json { render json: @dop.errors, status: :unprocessable_entity }
      end
    end
  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-06-06T09:45:01+00:00Added an answer on June 6, 2026 at 9:45 am

    You need to write a rake task and call that task through cron.

    For example:

    task :send_email => :environment do
      Dop.where('last_email <= ?', 7.days.ago).each do |dop|
        UserMailer.welcome_email(dop).deliver
        dop.update_attribute('last_email', Time.now)
      end
    end
    

    Now set up your machines Cron scheduler to call this Rake task every few minutes to send out emails automatically.

    Cron is a Unix scheduler that executes programs in pre-determined intervals.

    You need to edit the crontab file using crontab -e and enter something like this:

    */5 * * * *  /bin/bash cd <path_to_your_app> && rake send_email
    

    The */5 * * * * says that you run it every 5 minutes.

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

Sidebar

Related Questions

Possible Duplicate: sending mail with php & escaping hotmails junk folder I have been
Possible Duplicate: How to keep SVN from updating a directory already in repository everybody!
Possible Duplicate: What does it mean to “program to an interface”? I keep coming
Possible Duplicate: Run javascript function when user finishes typing instead of on key up?
Possible Duplicate: How to keep the browser history in sync when using Ajax? I
Possible Duplicate: Mouseout on specified divs and keep original div open I asked a
Possible Duplicate: splash screen for Universal application for ipad and iphone How to keep
Possible Duplicate: Python dictionary, keep keys/values in same order as declared If I have
Possible Duplicate: Javascript templating engines? I keep on stumbling upon javascript templating engines and
Possible Duplicate: Styling an input type=file button I was trying to style <input type=file>

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.