How to send SMTP emails in background

you've got at least two choices:

1) send your mail in a background process using backgroundrb (http://backgroundrb.rubyforge.org/) 2) use ar_mailer (http://blog.segment7.net/articles/2006/08/15/ar_mailer)

backgroundrb requires you to run a separate backgroundrb process, ar_mailer requires you to set up another database table for queueing the mail, and then running a cron job at a specified interval to send all the queued mail

Mike

Another choice is to use the Ruby Thread. You can read up on it here

http://www.rubycentral.com/pickaxe/ref_c_thread.html

I've had great success using it with all my background processing tasks. I just haven't found a situation where I needed backgroundrb, yet.

-- Long http://FATdrive.tv/wall/trakb/10-Long http://FATdrive.tv/ - store, play, share

In my case i used the Thread method. In this example i use msmtp, and send my email via GMail.

In environment.rb

ActionMailer::Base.delivery_method = :msmtp

module ActionMailer   class Base     def perform_delivery_msmtp(mail)       thread = Thread.new do         IO.popen("/usr/bin/msmtp -t -C /etc/.msmtprc -a gmail --", "w") do >sm>           sm.puts(mail.encoded.gsub(/\r/, ''))           sm.flush         end       end       thread.run     end   end end