[Backgroundrb-devel] backgroundrb / actionmailer / sendmail

Jason Lee jasonlee9 at gmail.com
Sat May 3 11:42:32 EDT 2008


Adam,

Not sure if it's a Rails 1.2.5 issue (I'm on 2.0.2). I've used the
scheduler before and found it not as reliable as Unix cron, so I moved
the scheduling code into the worker itself. I have BRb doing
background scheduled email tasks and it works quite well. Here's what
mine looks like:

class EmailWorker < BackgrounDRb::MetaWorker

  set_worker_name :Email_worker

  def create(args = nil)
    # time argument is in seconds
    add_periodic_timer(10) { process_orders }
  end

  def process
     # do some work
  end

end


My config looks like so (for development):

---
:backgroundrb:
    :ip: 0.0.0.0
    :port: 11006
    :environment: development


I removed all my scheduler code out of the config and it works well,
so maybe that will help.

- jason


On Fri, May 2, 2008 at 7:20 PM, Adam Kapelner <kapelner at gmail.com> wrote:
> Hello,
>
> I'm trying to send emails from a backgroundrb worker and the email doesn't
> send. I get no log messages in the sendmail log or the system log, nothing
> in the backgroundrb logs at all, nothing in the production log.
>
> Below is my code for each component
>
> worker:
>
> class QuizReviewerWorker < BackgrounDRb::MetaWorker
>    set_worker_name :quiz_review_sender
>
>    def create(args = nil)
>   end
>
>   def send_review_emails
>     mail = Notifier.create_test_email
>      status = Notifier.deliver(mail)
>     logger.info 'test mail:' + mail.body
>    end
> end
>
> mailer:
>
>  class Notifier < ActionMailer::Base
>
>   def test_email
>      recipients 'kapelner at gmail.com'
>     subject 'test email'
>      body 'body of email'
>     content_type "text/plain"
>    end
> end
>
> backgroundrb configuration:
>
>  ---
> :backgroundrb:
>    :ip: 0.0.0.0
>   :port: 11006
>    :environment: production
>   :debug_log: true
>  :schedules:
>   :quiz_review_sender:
>      :send_review_emails:
>       :trigger_args:
>          :start: <%= Time.now + 30.seconds %>
>         :end: <%= Time.now + 10.years %>
>          :repeat_interval: <%= 20.seconds %>
>
> environment.rb configuration:
>
> ActionMailer::Base.delivery_method = :sendmail
>  ActionMailer::Base.raise_delivery_errors = true
> ActionMailer::Base.default_content_type = 'text/html'
>
>
> Now, when doing the request from rails itself, no problem, I get the email
> instantly. Here's the controller code:
>
> class MiscellanyController < ApplicationController
>    def test_email
>     mail = Notifier.create_test_email
>      Notifier.deliver(mail)
>     render :text => mail.body
>    end
> end
>
>
> What could be the issue? I'm using Ruby 1.8.6, Rails 1.2.5, on Fedora Core
> 6, Backgroundrb (last updated 2008-02-28)
>
> thanks so much,
> Adam
>
>
>
>
>
>
> _______________________________________________
>  Backgroundrb-devel mailing list
>  Backgroundrb-devel at rubyforge.org
>  http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>


More information about the Backgroundrb-devel mailing list