# Fetcher Daemon Questions - receive?

**URL:** <https://www.ruby-forum.com/t/fetcher-daemon-questions-receive/122271>\
**Category:** Rails\
**Created:** [December 6, 2007, 3:32am UTC](https://www.ruby-forum.com/t/fetcher-daemon-questions-receive/122271 "2007-12-06T03:32:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dandiebolt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a87d85/32.png) [@dandiebolt](https://www.ruby-forum.com/u/dandiebolt)\
**Post date:** [December 6, 2007, 3:32am UTC](https://www.ruby-forum.com/t/fetcher-daemon-questions-receive/122271/1 "2007-12-06T03:32:21Z")

</div>

I’m starting to play with [Slantwise.com](http://Slantwise.com)’s Fetcher to process emails via  
a Ruby script.

Here’s the basic code lifted from their plugin:

```auto
class MailFetcherDaemon < Daemon::Base

  @config = YAML.load_file("#{RAILS_ROOT}/config/mail.yml")
  @config = @config[RAILS_ENV].to_options

  @sleep_time = @config.delete(:sleep_time) || 10

  def self.start
    puts "Starting MailFetcherDaemon"
    # Add your own receiver object below
    @fetcher = Fetcher.create({:receiver => nil}.merge(@config))

    loop do
      puts "checking mail"
      @fetcher.fetch
      sleep(@sleep_time)
    end
  end

  def self.stop
    puts "Stopping MailFetcherDaemon"
  end

end

MailFetcherDaemon.daemonize

```

my question is about receiver. According to the docs, such as they are,  
receiver is a class that is subclassed from ActiveMailer::Base. it needs  
to have a ‘receive’ method. Fine. I’ve created a class called Recipient,  
it lives in app\>models, and the mail.yml file uses it to find out the  
name of the class that is the receiver. When I start the daemon, it  
seems to start without complaint.

Here’s recipient.rb:

```auto
class Recipient < ActionMailer::Base

  def receive(msg)
    "got that"
  end

end
```

When running, the loop, on finding emails in the designated account is  
supposed to pass them one at a time to the receive method, and then  
delete the message.

The messages get deleted, so the daemon is running, and the login/pass  
to the account are in the mail.yml file, so that’s getting read. But the  
puts “got that” never appears in the console when I run it there on  
localhost.

What am I doing wrong???

Driving me nuts.

---

<div class="post-metadata">

**Author:** ![dandiebolt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a87d85/32.png) [@dandiebolt](https://www.ruby-forum.com/u/dandiebolt)\
**Post date:** [February 13, 2009, 10:26pm UTC](https://www.ruby-forum.com/t/fetcher-daemon-questions-receive/122271/2 "2009-02-13T22:26:40Z")

</div>

Did you ever figure out how to get up and running with this fetcher  
daemon??

I’m trying to get it working and so far, no luck…

[http://www.ruby-forum.com/topic/178498](http://www.ruby-forum.com/topic/178498)
