How to send emails later in Rails 5

July 18, 2019
I'm making an alternative to DevTools. Click here to check it out.

If you want to schedule an email to send after a certain period of time in Rails 5 – for instance, to send a welcome email the day after a user has created their account – you can use ActionMailer’s deliver_later method and add a wait_until parameter.

def create
  # ...


  # ...

There are a number of things you can do with this. Some ideas:

  • send the user an email when their trial is expiring
  • email the user if they haven’t completed the setup process
  • send the user a followup survey several weeks after they registered
  • send the user instructions if they got stuck on a certain part of your product

Don’t abuse this too much – only send email that’s truly important.