If you need to send a lot of emails from Ruby on Rails you may run into problems. Out of the box I was getting about 1 email/second through smtp from our low end server.
There’s an easy fix however!
put this in your environment.rb
ActionMailer::Base.delivery_method = :thread_smtp
module ActionMailer
class Base
def perform_delivery_thread_smtp(mail)
thread = Thread.new do
perform_delivery_smtp(mail)
end
thread.run
end
end
end
Doing this I was able to get smtp up to 13 emails/second with ruby’s smtp (there were a few DB calls as well for each email send). We use msmtp to send secure email, this has a similar configuration change. Using that I got up to 16 emails/second. I guess most things are faster than ruby.
Please do not use this technology for creating a spam engine, world domination, or evil.