MMS::Mail::Provider::UKTMobile - This provides a class for parsing an MMS::Mail::Message object that has been sent via the UK T-Mobile network.


MMS-Mail-Provider-UKTMobile documentation Contained in the MMS-Mail-Provider-UKTMobile distribution.

Index


Code Index:

NAME

Top

MMS::Mail::Provider::UKTMobile - This provides a class for parsing an MMS::Mail::Message object that has been sent via the UK T-Mobile network.

VERSION

Top

Version 0.04

SYNOPSIS

Top

This class provides a parse method for parsing an MMS::Mail::Message object into an MMS::Mail::Message::Parsed object for MMS messages sent from the UK T-Mobile network.

METHODS

Top

The following are the top-level methods of the MMS::Mail::Parser::UKTMobile class.

Constructor

new()

Return a new MMS::Mail::Provider::UKTMobile object.

Regular Methods

parse MMS::Mail::Message

The parse method is called as an instance method. It parses the MMS::Mail::Message object and returns an MMS::Mail::Message::Parsed object.

AUTHOR

Top

Rob Lee, <robl at robl.co.uk>

BUGS

Top

Please report any bugs or feature requests to bug-mms-mail-provider-uktmobile at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MMS-Mail-Provider-UKTMobile. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc MMS::Mail::Provider::UKTMobile

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/MMS-Mail-Provider-UKTMobile

* CPAN Ratings

http://cpanratings.perl.org/d/MMS-Mail-Provider-UKTMobile

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=MMS-Mail-Provider-UKTMobile

* Search CPAN

http://search.cpan.org/dist/MMS-Mail-Provider-UKTMobile

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


MMS-Mail-Provider-UKTMobile documentation Contained in the MMS-Mail-Provider-UKTMobile distribution.
package MMS::Mail::Provider::UKTMobile;

use warnings;
use strict;

use base 'MMS::Mail::Provider';

use MMS::Mail::Message::Parsed;

our $VERSION = '0.04';

sub parse {

  my $self = shift;
  my $message = shift;

  unless (defined $message) {
    return undef;
  }

  my $parsed = new MMS::Mail::Message::Parsed(message=>$message);

  my $text=undef;
  foreach my $element (@{$parsed->attachments}) {
    if ($element->mime_type eq 'text/plain') {
      my $header = $element->head;
      if ((defined $header->recommended_filename) && ($header->recommended_filename eq 'mms.txt')) {
        $text = $element->bodyhandle->as_string;
      }
    } elsif ($element->mime_type =~ /jpeg$/) {
      my $header = $element->head;
      if ( (defined $header->recommended_filename) && ($header->recommended_filename ne '')) {
        $parsed->add_image($element);
      }
    } elsif ($element->mime_type =~ /^video/) {
        $parsed->add_video($element);
    }
  }

  unless (defined $text) {
    return undef;
  }

  $parsed->header_subject($message->header_subject);
  $parsed->body_text($text);

  # Cleanup the header_from and set phone number
  $parsed->header_from =~ /\"(.+)\"/;
  $parsed->header_from($1);
  my ($num,undef) = split(/@/, $parsed->header_from);
  $parsed->phone_number($num);

  return $parsed;

}


1; # End of MMS::Mail::Provider::UKTMobile