Hi I get the following error message when I try to receive the mail shown below: ------ /home/wolfgang/rails-apps/mailman/script/runner:4: undefined method `[]'' for nil:NilClass (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/actionmailer-0.8.1/lib/action_mailer/vendor/tmail/quoting.rb:25:in `body'' from /home/wolfgang/rails-apps/mailman/script/../config/..//app/models/mailman.rb:9:in `receive'' from /usr/lib/ruby/gems/1.8/gems/actionmailer-0.8.1/lib/action_mailer/base.rb:155:in `receive'' from (eval):1 ------ mail: ------>From wolfgang-8VoAFZuWeemsTnJN9+BGXg@public.gmane.org Mon Apr 4 09:56:21 2005Return-Path: <wolfgang-8VoAFZuWeemsTnJN9+BGXg@public.gmane.org> X-Original-To: wolfgang Delivered-To: wolfgang-8VoAFZuWeemsTnJN9+BGXg@public.gmane.org Received: by xxxxxx (Postfix, from userid 1000) id 33DE8152B1; Mon, 4 Apr 2005 09:56:21 +0000 (UTC) To: wolfgang-8VoAFZuWeemsTnJN9+BGXg@public.gmane.org Subject: test Message-Id: <20050404095621.33DE8152B1@xxxxxx> Date: Mon, 4 Apr 2005 09:56:21 +0000 (UTC) From: wolfgang@xxxxxx (Wolfgang) Content-Length: 5 Lines: 1 test ------ and here''s my model: ------ class Mailman < ActionMailer::Base def receive(email) mail = Mail.new mail.from = email.from.first mail.to = email.to.first mail.subject = email.subject # the following line makes problems, without it it works flawlessly mail.body = email.body mail.save end end ------ If I delete the single line "mail.body = email.body" it works!! I really hope somebody can take a look at it, tia! I can''t see the difference to http://wiki.rubyonrails.com/rails/show/HowToReceiveEmailsWithActionMailer bye Wolfgang
Hi! On Mon, 04 Apr 2005, Wolfgang Klinger wrote the following:> class Mailman < ActionMailer::Base > def receive(email) > mail = Mail.new > mail.from = email.from.first > mail.to = email.to.first > mail.subject = email.subject > # the following line makes problems, without it it works flawlessly > mail.body = email.body > mail.save > end > endcat ~/testmail | script/runner ''Mailman.receive(STDIN.read)'' "print email.inspect" returns: ---- /usr/lib/ruby/gems/1.8/gems/actionmailer-0.8.1/lib/action_mailer/vendor/tmail/port.rb:310: warning: Object#id will be deprecated; use Object#object_id #<TMail::Mail port=#<TMail::StringPort:id=0x..fdbd0f854> bodyport=nil> ---- and "print email" returns the raw(!?) mail! and then I tried the same in irb: ---- irb(main):001:0> require ''tmail'' => true irb(main):002:0> mail = TMail::Mail.parse(`cat ~/testmail`) => #<TMail::Mail port=#<TMail::StringPort:id=0x..fdbdf6d3c> bodyport=nil> irb(main):003:0> mail.inspect => "#<TMail::Mail port=#<TMail::StringPort:id=0x..fdbdf6d3c> bodyport=nil>" irb(main):004:0> mail.subject => "test" irb(main):005:0> mail.body => "test\n\n" irb(main):006:0> mail.to => ["wolfgang@xxxxxxx"] irb(main):007:0> mail.from => ["wolfgang@xxxxxxx"] irb(main):008:0> mail => #<TMail::Mail port=#<TMail::StringPort:id=0x..fdbdf6d3c> bodyport=#<TMail::StringPort:id=0x..fdbdf432a>> ---- and there it works... hmmm... it seems like the parsing doesn''t work... any thoughts? tia, kind regards Wolfgang
Hi Wolfgang! ;-) On Tue, 05 Apr 2005, Wolfgang Klinger wrote the following:> and there it works... hmmm... it seems like the parsing doesn''t work...solved, patch is available here: http://dev.rubyonrails.com/ticket/1036 bye Wolfgang