Best practices for email delivery in production

In pre Rails 3 world I was using ar_sendmail to queue up emails. Then I would setup a cron job every few minutes to deliver the emails. But that doesn't work perfectly in Rails 3. What is the best way to deliver emails in production environment in Rails 3?

Have a look at running some kind of delayed job queue - I use Resque normally, which I think comes from GitHub. With Resque, and ResqueMailer (another gem) you can simply “include Resque::Mailer” in your mailers to have them automatically queued for delivery. Hope that helps.

We just set up a daemon (#129 Custom Daemon - RailsCasts), which is the same idea, but it runs inside your app's environment. To send an email from our app, we just add a row to a table. Then the daemon wakes up every minute, clears out that table, and sends the email.

Is there a way to use beanstalkd and stalker to replicate ar_sendmail functionality?

Hi Amy, you might want to try SimpleWorker at http://www.simpleworker.com , great for sending emails (or doing anything in batch) and very easy to use, no setup required.

Here’s a sample email worker: http://support.simpleworker.com/kb/sample-workers/emailworker-send-emails-in-the-background-or-schedule-for-later

Travis