Class MMS2R::Media::Sprint
In: lib/mms2r/media/sprint.rb
Parent: MMS2R::Media
Media MMS2R dot/f_1.png

Sprint version of MMS2R::Media

Sprint is an annoying carrier because they don’t actually transmit user generated content (like images or videos) directly in the MMS message. Instead, they hijack the media that is sent from the cellular subscriber and place that content on a content server. In place of the media the recipient receives a HTML message with unsolicited Sprint advertising and links back to their content server. The recipient has to click through Sprint more pages to view the content.

The default subject on these messages from the carrier is “You have new Picture Mail!“



Public Instance methods

Override process() because Sprint doesn’t attach media (images, video, etc.) to its MMS. Media such as images and videos are hosted on a Sprint content server. MMS2R::Media::Sprint has to pick apart an HTML attachment to find the URL to the media on Sprint’s content server and download each piece of content. Any text message part of the MMS if it exists is embedded in the html.


# File lib/mms2r/media/sprint.rb, line 39
      def process
        unless @was_processed
          log("#{self.class} processing", :info)
          #sprint MMS are multipart
          parts =

          #find the payload html
          doc = nil
          parts.each do |p|
            next unless p.part_type? == 'text/html'
            d = Nokogiri(p.body)
            title ='title').inner_html
            if title =~ /You have new Picture Mail!/
              doc = d
              @is_video = (p.body =~ /type="VIDEO">/m ? true : false)
          return if doc.nil? # it was a dud
          @is_video ||= false
          # break it down
          @was_processed = true

        # when process acts upon a block
        if block_given?
          media.each do |k, v|
            yield(k, v)