BACKTRACE

(condense)

Back to Posts List

GET

Mean Mail Machine

i was trying the other day to create some sort of a newsletter. sadly it took me about 2 hours to generate and send 51000 emails (not spam :) ) so i tried to find a way to do it a little faster.
a friend of mine came across the idea of using threads so i tried to override the basics of ActionMailer in order to make the delivery method to user threads.
the change boosted me up to 18-20 mails per second, in other words, 1900% more efficient!
here is the code, just push it in your environment.rb (or lib, whatever), just don’t use it for mean/nasty/microsoft needs :).

  1. ActionMailer::Base.delivery_method = :thread_smtp  
  2.   module ActionMailer  
  3.     class Base  
  4.       def perform_delivery_thread_smtp(mail)  
  5.         thread = Thread.new do  
  6.           perform_delivery_smtp(mail)  
  7.         end  
  8.         thread.run   
  9.       end  
  10.   end  
  11. end  

POST

blog comments powered by Disqus

I Don't have cookies.

ELAD ENV

Variable Value
LINKEDIN
TWITTER
FACEBOOK
GITHUB
WWR
IRC
{ 'irc.freenode.net' => [ '#rubyonrails', '#railsbridge', '#ruby', '#mootools' ]}
SKYPE
eladmeidar

You're seeing this error because I think it is funny.