Skip to content

Instantly share code, notes, and snippets.

@monde
Created July 23, 2010 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save monde/486883 to your computer and use it in GitHub Desktop.
Save monde/486883 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment