schedule the sending of an email in rails

Mike

I need to send an email 3 months after the client registered, I am using the gem exchange program, for now I send an email when the client registers, but I need to do both.

Gustavo Gabriel

You need to have some kind of gem to do cron jobs, like whenever. Or just use regular linux cron to run your script directly, and then program it to run every day.

And then the script to check when users registered:

User.where(sent_email: false).each do |user|
    if user.registered_date + 3.months < Time.now
        #send email
        user.update(sent_email:true)
    end
end

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related