Why would I receive an error message that looks like this:
<2optin_railshq_net@localhost.railshq.net> (expanded from
<2optin@railshq.net>): Command died with status 1:
"/opt/ruby-enterprise-1.8.6-20090610/bin/ruby
/var/www/rails/railshq.net/script/runner
'Emailer.receive2optin(STDIN.read)'". Command output:
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/
rails-2.3.2/lib/commands/runner.rb:48:
undefined method `receive2optin' for Emailer:Class
(NoMethodError) from
When my action mailer class looks like this:
class Emailer < ActionMailer::Base
# First method omitted for simplicity
def receive2optin(email)
outfile=File.open('/tmp/debug1','w')
outfile.puts(email.from[0])
outfile.close
end
end
Why would I receive an error message that looks like this:
<2optin_railshq_net@localhost.railshq.net> (expanded from
<2optin@railshq.net>): Command died with status 1:
"/opt/ruby-enterprise-1.8.6-20090610/bin/ruby
/var/www/rails/railshq.net/script/runner
'Emailer.receive2optin(STDIN.read)'". Command output:
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/
rails-2.3.2/lib/commands/runner.rb:48:
undefined method `receive2optin' for Emailer:Class
(NoMethodError) from
When my action mailer class looks like this:
class Emailer < ActionMailer::Base
# First method omitted for simplicity
def receive2optin(email)
outfile=File.open('/tmp/debug1','w')
outfile.puts(email.from[0])
outfile.close
end
end
Short, smart ass answer: the script calls a class method, the code defines an
instance method. However, ActionMailer has some smoke and mirrors so that if
you change the script to call Emailer.deliver_receive2optin(STDIN.read), it
will do what you probably want.
Short, smart ass answer: the script calls a class method, the code defines an
instance method. However, ActionMailer has some smoke and mirrors so that if
you change the script to call Emailer.deliver_receive2optin(STDIN.read), it
will do what you probably want.
Wow!! I doubt that I would have ever figured that out. I have read
tons of documentation on the "receiving email" issue and I've never
seen any mention of this.
So, you've now bailed me out on two issues and this one finally put me
over the top. It now works!
I was under the impression that my email argument was an object so
that I could extract things like email.body and email.from[0]. That
doesn't seem to be the case. email doesn't appear to be an object at
all but rather just a variable containing the full text of the email
including both header and body. It would be really nice if I had an
object so that I could conveniently get at the respective
components.
In any event, you've been most helpful. The proof of the pudding is
in the eating, and IT WORKS! Thanks a batch for the help.