Plasticx Blog

Capable of being shaped or formed

MMS2R working in Rails 2.3.x and 3.x

Posted by Mike 08/17/2010 at 11:53AM

I should have been more vocal about this change in MMS2R. Back in February of this year I released MMS2R version 3.0.0 and starting with that version it was dependent upon the Mail gem, rather than TMail. As you might be aware, Mail is the mail gem that ActionMailer is using in Rails 3. Your "legacy" Rails 2.*.* application can still get the benefits of the latest MMS2R versions even though TMail is used by the older ActionMailers.

Here is an example of patching ActionMailer::Base in a way that we can ignore the TMail object it passes to it's #receive method and instantiate a Mail object that we can use with MMS2R.

class MailReceiver < ActionMailer::Base

  # RAILS 2.*.* ONLY!!!

  # 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

Here is a Gist of the above code where you can fork your own copy, etc. http://gist.github.com/486883.

Not to brag or anything, but I heard twitpic is using MMS2R in part of it's application.

Thank you and enjoy!

Posted in , , |

MMS2R 2.3.0, now with exif, used in Rails apps and Y Combinator startups

Posted by Mike 08/31/2009 at 11:10PM

I just published a minor point release of the MMS2R Gem version 2.3.0 (http://mms2r.rubyforge.org/). If you were not aware, MMS2R is really just a generic multi-part mail processor. If you have a Ruby application ( Rails, Sinatra, Camping, etc.) and it is processing attachments out of email and/or MMS data, then MMS2R is the gem you should be using. MMS2R has many convenience methods to fetch the most likely image attachment, text attachment, etc. It now gives access to any JPEG or TIFF's exif data using the exifr (http://exifr.rubyforge.org/) reader gem. For instance, MMS2R uses the exif data to detect if the source of the message is from a smartphone like an iPhone or BlackBerry, it could be used for other logic as well.

Back in the summer of 2007 I almost wrote a twitpic.com app using MMS2R, but I couldn't make time for myself to do so. MMS2R would have processed the email extracting images that I had taken with my phone, I would then have posted those to S3 referenced with tiny url links (using Camping Hurl http://github.com/monde/hurl/) into my Twitter feed. I had written MMS2R even earlier than that time, but the emphasis has always been to make it easy to get at MMS data so that it can be used easily in all kinds of applications, social applications in particular.

There are two places to start looking for ideas on how to use MMS2R in a Rails application as I've just described. The first is the PeepCode book Luke Francl (http://justlooking.recursion.org/) and I wrote about it: "Receiving Email With Ruby" http://peepcode.com/products/mms2r-pdf

Another is a recent Rails Magazine article by By Jason Seifer (http://jasonseifer.com/) is titled "Receiving E-Mail With Rails" http://railsmagazine.com/articles/3

There are a number of startups and web sites listed on the MMS2R RubyForge page (http://mms2r.rubyforge.org/) that are using the Gem in their application stack. One of those is Luke's FanChatter (http://www.fanchatter.com/). At the beginning of the summer Fan Chatter received startup funding from Y Combinator (http://ycombinator.com/). So if you use MMS2R in your social Rails application, it might improve your chances of being funded by Y Combinator. Congratulations Luke.

Posted in , , |

MMS2R : Making email useful

Posted by Mike 06/04/2008 at 01:00AM

Last month before RailsConf Luke Francl and I published "MMS2R : Making email useful" on PeepCode. Its a PDF book so kill all the trees that you can buying it. The book is awesome because of the diversity of experience that Luke brings to the book and Geoffrey Grosenbach is a fabulous editor.

We cover a wide range of experience dealing with MMS in Rails and other applications. An overview is:

  • Introduction (protocol, mobile networks, gateways, etc.)
  • A Brief History (MMS integrated with web apps, etc.)
  • Processing MMS
  • Working with ActionMailer (e.g. Rails, daemonizing Rails, IMAP & POP fetching)
  • Testing (Test::Unit & RSpec)
  • Advanced Topics

MMS2R handles more than just MMS

You may not be aware of this but MMS are just multi-part MIME encoded email. And Luke likes to say that MMS2R is good for email in general not just MMS. MMS2R pulls apart multipart email in an intelligent manner and gives you access to its content in an easy fashion. It writes each part decoded to temporary files and provides a duck typed CGI File so that it is easily integrated with attachment_fu.

Pimp my WWR

I put a lot work into MMS2R so that its easy to access user generated content in an intelligent fashion. Recommend me on Working With Rails if you’ve benefited from this experience and thank you in advance!

Friends of MMS2R

MMS2R and our book would not have been possible without the help of these awesome people from the open source community:

Posted in , , , , |

mms2r 2.0.0 Released

Posted by Mike 01/23/2008 at 02:15PM

mms2r version 2.0.0 has been released!

Upcoming!

DESCRIPTION:

MMS2R is a library that decodes the parts of an MMS message to disk while
stripping out advertising injected by the mobile carriers. MMS messages are
multipart email and the carriers often inject branding into these messages. Use
MMS2R if you want to get at the real user generated content from a MMS without
having to deal with the cruft from the carriers.

If MMS2R is not aware of a particular carrier no extra processing is done to the
MMS other than decoding and consolidating its media.

Contact the author to add additional carriers to be processed by the library.
Suggestions and patches appreciated and welcomed!

Corpus of carriers currently processed by MMS2R:

  • Alltel: message.alltel.com
  • AT&T/Cingular/Legacy: mms.att.net, txt.att.net, mmode.com, mms.mycingular.com,
    cingularme.com
  • Dobson/Cellular One: mms.dobson.net
  • Helio: mms.myhelio.com
  • Hutchison 3G UK Ltd: mms.three.co.uk
  • LUXGSM S.A.: mms.luxgsm.lu
  • NetCom (Norway): mms.netcom.no
  • Nextel: messaging.nextel.com
  • O2 Germany: mms.o2online.de
  • Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr
  • PXT New Zealand: pxt.vodafone.net.nz
  • Sprint: pm.sprint.com, messaging.sprintpcs.com
  • T-Mobile: tmomail.net
  • Verizon: vzwpix.com, vtext.com

Changes:

1.2.0 / 2008-01-23 (Skwisgaar Skwigelf – fastest guitarist alive)

  • added support for pxt.vodafone.net.nz PXT New Zealand
  • added support for mms.o2online.de O2 Germany
  • added support for orangemms.net Orange UK
  • added support for txt.att.net AT&T
  • added support for mms.luxgsm.lu LUXGSM S.A.
  • added support for mms.netcom.no NetCom (Norway)
  • added support for mms.three.co.uk Hutchison 3G UK Ltd
  • removed deprecated #get_number use #number
  • removed deprecated #get_subject use #subject
  • removed deprecated #get_body use #body
  • removed deprecated #get_media use #default_media
  • removed deprecated #get_text use #default_text
  • removed deprecated #get_attachment use #attachment
  • fixed error when Sprint content server responds 500
  • better yaml configs
  • moved TMail dependency from Rails ActionMailer SVN to ‘official’ Gem
  • ::new greedily processes MMS unless otherwise specified as an initialize
    option :process => :lazy
  • logger moved to initialize option :logger => some_logger
  • testing using mocks and stubs instead of duck raped Net::HTTP
  • fixed typo in name of method #attachement to #attachment
  • fixed broken downloading of Sprint videos

Posted in , , |

Last blog post of 2007?

Posted by Mike 12/11/2007 at 02:10PM

Synopsis

I’ve been in a writers block for useful bits of information to post on my blog. I guess I’ll give a summary of things I’ve seen and done lately and perhaps that will inspire others.

Work

I started my own S-Corp. to work freelance out of over the summer. I was motivated to do so after attending the The Business of Rails session at RubyConf 2007. And I’ve gotten a lot of great tips on how to be a business person in Rails from the Google group Ruby on Rails meets the business world

I started consulting through Contentfree over the summer. They are a Rails consulting shop and have been working on a startup for their Eachday photo and memories sharing site. Its been great to working with Dave Myron there. Dave is one of the best coders and software designers I’ve ever worked with and I’m not saying that just to get more work!

RubyConf

I went to RubyConf 2007. It was fun. I played a lot of Werewolf (see #53) in the evenings. Sadly, it felt like the close knit party was/is over in the Ruby community since all the momentum that Rails has brought to Ruby is bringing in the masses (I’m in that group, one of “those guys”). My guess is that RailsConf 2008 is going to feel like a JavaOne, and RubyConf 2008 will feel like RailsConf 2007 with to many tracks.

#fauna

At RubyConf I got to meet the people I’ve met in the #fauna channel on irc.freenode.net. I think some of the greatest Ruby code and ideas I’ve been exposed to are from people in that channel. Shout outs to adamblock, agile, evn, lifo, heaveysixer, loincloth, defunkt, and others.

Evan Weaver

Evan is a genius and pretty cool dude.

Pratik

Pratik is a genius and is very active on RailsCore contributions. He says Just Say No To Named Spaced Models so I guess you should ignore this post: Rails Models in a Namespace

Chris Wanstrath

Chris is a genius is full of ambition Ambition Google Group

ditching Typo

I’m probably going to ditch this Typo blog when I can make time to do it. I’ll either go with an another Rails based blog called Mephisto or Evan Weaver’s Bax blog which uses scripts and Apache SSI and is hidden on fauna’s SVN on Ruby Forge: ‘svn co svn://rubyforge.org/var/svn/fauna/bax’

like Ozimodo

I’ve been thinking about doing a Camping based tumblelog. I even paid a designer to make a template for it. I’ll blog about that latter. It will be like Ozimodo and probably steel code from it.

imPOSTor

I’m sitting on a Gem called imPOSTor that will post comments to forums such as phpBB and Web Wiz Forums . I’ll probably release within the month. It has been working inside a production grade private Rails app for over a month so I think its ready to be released. “The imPOSTor library is used to automate the act of posting comments and data to forums such as phpBB and WWF. impostor encapsulates the work of posting to these forums using a common (ruby) interface.”

MMS2R

I’m about to finish the next major version of MMS2R (2.0) . I think I’ve found the best architecture for it be maintained for the long haul. Each release of MMS2R is named after a character in the Metalocalypse cartoon.

Speaking of MMS2R Luke Francl and I submitted a MMS + Rails proposal for RubyConf 2008 called “Mobile Messaging with Rails”. Luke and I are also writing a PeepCode book about Rails+MMS+Mobile phones.

Posted in , , , , , , , |

mms2r 1.1.8 Released

Posted by Mike 09/08/2007 at 01:45AM

mms2r version 1.1.8 has been released!

  • <http://mms2r.rubyforge.org/>

DESCRIPTION:

MMS2R is a library that decodes the parts of an MMS message to disk while
stripping out advertising injected by the cellphone carriers. MMS messages are
multipart email and the carriers often inject branding into these messages. Use
MMS2R if you want to get at the real user generated content from a MMS without
having to deal with the cruft from the carriers.

If MMS2R is not aware of a particular carrier no extra processing is done
to the MMS other than decoding and consolidating its media.

Contact the author to add additional carriers to be processed by the
library. Suggestions and patches appreciated and welcomed!

Corpus of carriers currently processed by MMS2R:

  • AT&T => mms.att.net
  • AT&T/Cingular => mmode.com
  • Cingular => mms.mycingular.com
  • Cingular => cingularme.com
  • Dobson/Cellular One => mms.dobson.net
  • Helio => mms.myhelio.com
  • Nextel => messaging.nextel.com
  • Orange (Poland) => mmsemail.orange.pl
  • Orange (France) => orange.fr
  • Sprint => pm.sprint.com
  • Sprint => messaging.sprintpcs.com
  • T-Mobile => tmomail.net
  • Verizon => vzwpix.com
  • Verizon => vtext.com

Changes:

1.1.8 / 2007-09-08 (James Grishnack – Head of Behemoth Productions, producer
of Blood Ocean)

  • Added support for Orange of France, Orange orange.fr (Julian Biard)
  • purge in the process block removed, purge must be called explicitly
    after processing to clean up extracted temporary media files.

Posted in , |

mms2r 1.1.7 Released

Posted by Mike 08/27/2007 at 11:31AM

mms2r version 1.1.7 has been released!

http://mms2r.rubyforge.org/

DESCRIPTION:

MMS2R is a library that decodes the parts of an MMS message to disk while
stripping out advertising injected by the cellphone carriers. MMS messages are
multipart email and the carriers often inject branding into these messages. Use
MMS2R if you want to get at the real user generated content from a MMS without
having to deal with the cruft from the carriers.

If MMS2R is not aware of a particular carrier no extra processing is done
to the MMS other than decoding and consolidating its media.

Contact the author to add additional carriers to be processed by the
library. Suggestions and patches appreciated and welcomed!

Corpus of carriers currently processed by MMS2R:

  • AT&T => mms.att.net
  • AT&T/Cingular => mmode.com
  • Cingular => mms.mycingular.com
  • Cingular => cingularme.com
  • Dobson/Cellular One => mms.dobson.net
  • Helio => mms.myhelio.com
  • Nextel => messaging.nextel.com
  • Orange (Poland) => mmsemail.orange.pl
  • Sprint => pm.sprint.com
  • Sprint => messaging.sprintpcs.com
  • T-Mobile => tmomail.net
  • Verizon => vzwpix.com
  • Verizon => vtext.com

Changes:

== 1.1.7 / 2007-08-25 (Adam Nergal, friend of Skwisgaar, but not Pickles)

  • Added suport for Orange of Poland Orange mmsemail.orange.pl (Zbigniew
    Sobiecki)
  • Cleaned up documentation modifiers
  • Cleaned out non-Ruby code idioms

http://mms2r.rubyforge.org/

Posted in , , |

mms2r 1.1.4 Released

Posted by Mike 08/07/2007 at 12:46AM

mms2r version 1.1.4 has been released!

  1. DESCRIPTION:

MMS2R is a library that decodes the parts of an MMS message to disk while
stripping out advertising injected by the cellphone carriers. MMS messages are
multipart email and the carriers often inject branding into these messages. Use
MMS2R if you want to get at the real user generated content from a MMS without
having to deal with the cruft from the carriers.

If MMS2R is not aware of a particular carrier no extra processing is done
to the MMS other than decoding and consolidating its media.

Contact the author to add additional carriers to be processed by the
library. Suggestions and patches appreciated and welcomed!

Corpus of carriers currently processed by MMS2R:

  • AT&T => mms.att.net
  • AT&T/Cingular => mmode.com
  • Cingular => mms.mycingular.com
  • Cingular => cingularme.com
  • Dobson/Cellular One => mms.dobson.net
  • Helio => mms.myhelio.com
  • Nextel => messaging.nextel.com
  • Sprint => pm.sprint.com
  • Sprint => messaging.sprintpcs.com
  • T-Mobile => tmomail.net
  • Verizon => vzwpix.com
  • Verizon => vtext.com

Changes:

  1. 1.1.4 / 2007-08-07 (Dr. Rockso)
  • AT&T => mms.att.net support (thanks Mike Chen and Dave Myron)
  • get_body returns nil when there is not user text (sorry Will!)

Posted in , , |

mms2r 1.1.3 Released

Posted by Mike 07/10/2007 at 10:33AM

mms2r version 1.1.3 has been released!

DESCRIPTION:

MMS2R is a library that decodes the parts of an MMS message to disk while
stripping out advertising injected by the cellphone carriers. MMS messages are
multipart email and the carriers often inject branding into these messages. Use
MMS2R if you want to get at the real user generated content from a MMS without
having to deal with the cruft from the carriers.

If MMS2R is not aware of a particular carrier no extra processing is done
to the MMS other than decoding and consolidating its media.

Contact the author to add additional carriers to be processed by the
library. Suggestions and patches appreciated and welcomed!

Corpus of carriers currently processed by MMS2R:

  • AT&T/Cingular => mmode.com
  • Cingular => mms.mycingular.com
  • Cingular => cingularme.com
  • Dobson/Cellular One => mms.dobson.net
  • Helio => mms.myhelio.com
  • Nextel => messaging.nextel.com
  • Sprint => pm.sprint.com
  • Sprint => messaging.sprintpcs.com
  • T-Mobile => tmomail.net
  • Verizon => vzwpix.com
  • Verizon => vtext.com

Changes:

  1. 1.1.3 / 2007-07-10 (Charles Foster Ofdensen)
  • Helio support by Will Jessup
  • get_subject returns nil on default carrier subjects

http://mms2r.rubyforge.org/

Posted in , |

handling a rcov non-dependency in your gem on firebrigade

Posted by Mike 06/11/2007 at 11:25AM

MMS2R was not showing any tests in its firebridge entry because I had a non-dependency for a rcov task that I had included in the MMS2R gem’s Rakefile

This is what Eric says on firebrigade:

Depend on what you need so that your tests will work. For example, if you have an rcov task, but you don’t want to mark it as a dependency, wrap it in a rescue block. Tinderbox is friendly enough to add Rake or RSpec as a dependency if you forgot it, but other than that, you’re on your own.

This is how to rescue the LoadError exception around the require statement for rcov in the Rakefile :

begin
  require 'rcov/rcovtask'
rescue LoadError
end

and this is how I rescue the NameError exception in the rcov task:

begin
  Rcov::RcovTask.new do |t|
    t.test_files = FileList['test/test*.rb']
    t.verbose = true
    t.rcov_opts << "--exclude rcov.rb,hpricot.rb,hpricot/.*\.rb"
  end
rescue NameError
end

update

07/04/2007

Actually MMS2R is not being tested on the firebrigade currently. The problem stems from a bug in Gems 0.9.4 where MMS2R being dependent on Hpricot and Tinderbox getting a Gem::RemoteInstallationCancelled exception (line 106 of lib/tinderbox/gem_runner.rb) that Eric transforms into a Tinderbox::ManualInstallError


/usr/local/lib/ruby/gems/1.8/gems/tinderbox-1.0.0/lib/tinderbox/gem_runner.rb:108:in `install’: Installation of mms2r-1.1.2 requires manual intervention (Tinderbox::ManualInstallError)
from /usr/local/lib/ruby/gems/1.8/gems/tinderbox-1.0.0/lib/tinderbox/gem_runner.rb:265:in `run’
from /usr/local/lib/ruby/gems/1.8/gems/tinderbox-1.0.0/bin/tinderbox_gem_build:9
from /usr/local/bin/tinderbox_gem_build:16:in `load’
from /usr/local/bin/tinderbox_gem_build:16

Eric says its an known bug in Gems 0.9.4 and should bug them about it!

update

08/01/2007

Eric says that “automatic platform selection to RubyGems” will be fixed on his vacation

Posted in , , , |


Web Statistics