I''m starting to play with Slantwise.com''s Fetcher to process
emails via
a Ruby script.
Here''s the basic code lifted from their plugin:
[code]
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
[/code]
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:
[code]
class Recipient < ActionMailer::Base
def receive(msg)
"got that"
end
end
[/code]
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.
--
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
-~----------~----~----~----~------~----~------~--~---