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.
you’ve got at least two choices:
- send your mail in a background process using backgroundrb
- use 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
Another choice is to use the Ruby Thread. You can read up on it here
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.
http://FATdrive.tv/ - store, play, share
----- Original Message -----
From: “Mike G.” [email protected]
To: [email protected]
Sent: Friday, March 14, 2008 2:31 PM
Subject: [Rails] Re: How to send SMTP emails in background
In my case i used the Thread method.
In this example i use msmtp, and send my email via GMail.
ActionMailer::Base.delivery_method = :msmtp
thread = Thread.new do
IO.popen("/usr/bin/msmtp -t -C /etc/.msmtprc -a gmail --",