Permalink
Browse files

Notes on how to hack Mail into Rails 2.3.* ActionMailer

  • Loading branch information...
1 parent 47b9c03 commit f8f6aa6f1b385ba088e85e1a64149eb5d303c0c1 @monde committed Jul 24, 2010
Showing with 32 additions and 0 deletions.
  1. +32 −0 README.TMail.txt
View
@@ -9,3 +9,35 @@ publish point releases for 2.4.X. But I may not so don't count on it. Version
the Mail gem.
Thank you
Mike
+
+7/24/2010
+If you want to use Mail instead of TMail in an Rails 2.3 or lower ActionMailer
+this is one way to do it:
+
+http://gist.github.com/486883
+
+
+class MailReceiver < ActionMailer::Base
+
+ # patch ActionMailer::Base to put a ActionMailer::Base#raw_email
+ # accessor on the created instance
+ class << self
+ alias :old_receive :receive
+ def receive(raw_email)
+ send(:define_method, :raw_email) { raw_email }
+ self.old_receive(raw_email)
+ end
+ end
+
+ ##
+ # Injest email/MMS here
+
+ def receive(tmail)
+ # completely ignore the tmail object rails passes in Rails 2.*
+
+ mail = Mail.new(self.raw_email)
+ mms = MMS2R::Media.new(mail, :logger => Rails.logger)
+
+ # do something
+ end
+end

0 comments on commit f8f6aa6

Please sign in to comment.