[Backgroundrb-devel] problems with ActionMailer

Rolando Abarca funkaster at gmail.com
Mon Aug 7 00:16:31 EDT 2006

Hi all,
I'm trying to create a worker to send a mail to all the users in my
db. Right now I'm doing the tests, this is the code in my worker
(Masivo is the ActionMailer subclass):

  def do_work(args)
    @progress = 0
    @logger.info("MAILER: starting job")
    records = Record.find(:all)
    total = records.size
    records.each_with_index do |record, idx|
      recipients = record.emails.to_a
      email = Masivo.create_mail_prueba(recipients)
      sleep(10) # this is here for testing purposes
    @logger.info("MAILER: job done")
    @progress = 100

this is the code in Masivo:

  def mail_prueba(recipients)
    @recipients = recipients
    @from = "myself at mydomain.com"
    @subject = "test email"
    @sent_on = Time.now
    @body = {}

If I do this, I get an exception:

No rhtml, rxml, rjs or delegate template found for mail_prueba -

I had to put a render :file at the end of the mail_prueba function,
and even that way the email is not sent... Any ideas on what could be
the problem?

btw... this is the code in the controller that creates the worker:

  def email_prueba
    MiddleMan.new_worker(:class => :mailer_worker, :args => "",
:job_key => :emailer)
    redirect_to(:action => 'email_prueba_progress')

  def email_prueba_progress
    render(:text => "Progreso: #{MiddleMan[:emailer].progress}")

thanks for any hint.
rolando -- [[ knowledge is empty, fill it ]] --
"Tam pro papa quam pro rege bibunt omnes sine lege."

More information about the Backgroundrb-devel mailing list