My application sends emails with SMTP but I have a problem: It is very slow, so every time my application sends an email it goes very slow. I wonder if there is any kind of mode to do all the SMTP in background. I mean, I would like to continue sending SMTP emails but I would like my app not to go slow every time it sends an email. The app should do all the business about sending the email in background. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On 3/14/08, John Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > My application sends emails with SMTP but I have a problem: It is very > slow, so every time my application sends an email it goes very slow. > > I wonder if there is any kind of mode to do all the SMTP in background. > I mean, I would like to continue sending SMTP emails but I would like my > app not to go slow every time it sends an email. The app should do all > the business about sending the email in background. > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
John, If you are on a linux system, pipe the email to sendmail instead. It will take care of the queueing, etc for you and will send it by SMTP itself, instead of your module having to rely on an SMTP connection. It looks like ActionMailer::Base has a "delivery_method" option, if you set it to "sendmail" it should just start piping them out via sendmail instead of SMTP. - Tyler John Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > My application sends emails with SMTP but I have a problem: It is very > slow, so every time my application sends an email it goes very slow. > > I wonder if there is any kind of mode to do all the SMTP in background. > I mean, I would like to continue sending SMTP emails but I would like my > app not to go slow every time it sends an email. The app should do all > the business about sending the email in background. > -- > Posted via http://www.ruby-forum.com/. > > >-- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 ----- Original Message ----- From: "Mike Garey" <random52k-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Sent: Friday, March 14, 2008 2:31 PM Subject: [Rails] Re: 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 > > On 3/14/08, John Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > My application sends emails with SMTP but I have a problem: It is very > > slow, so every time my application sends an email it goes very slow. > > > > I wonder if there is any kind of mode to do all the SMTP in background. > > I mean, I would like to continue sending SMTP emails but I would like my > > app not to go slow every time it sends an email. The app should do all > > the business about sending the email in background. > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---