NAME

Catalyst::Controller::MIME - Multipart MIME viewer via Catalyst

SYNOPSIS

package MyApp::Controller::MimeView;
use Moose;
use namespace::autoclean;
use Email::MIME;

BEGIN {extends 'Catalyst::Controller::MIME'; }

sub get_mime {
  my ($self, $c, $id) = @_;
  
  my $mime_content = $c->model('SomeModel')->get_content_by_id($id)
    or return undef;
  
  return Email::MIME->new($mime_content);
}

1;

Then, access URLs like the following to view MIME objects:

# View MIME object with id '1234'
http://localhost:3000/mimeview/view/1234

# View part 1 of a MIME object with id '1234'
http://localhost:3000/mimeview/view/1234/1

# View part 3 of part 1 of a MIME object with id '1234'
http://localhost:3000/mimeview/view/1234/1/3

# Download MIME object with id '1234'
http://localhost:3000/mimeview/content/1234

DESCRIPTION

Quick and dirty Catalyst Controller interface for viewing MIME objects, including multipart MIME objects with rich content and embedded images, such as those typically generated by rich-text E-Mails and MHTML files. This module might be used as an E-Mail viewer, but can also be used to view any MIME content, including *.mht files, image attachments, and so on.

METHODS

get_mime

Method to be defined in consuming class used to resolve an id into an Email::MIME object. Must return an Email::MIME object. See Synopsis above for example.

CONFIG PARAMS

get_mime_coderef

Alternative way to supply the get_mime() method as a CodeRef that can be passed as a config param. If defined, the real get_mime method will be ignored.

expose_methods

Bool option for debug purposes. Allows calling methods on the Email::MIME object directly and dumping the output. For example:

# Dump the output of $MIME->debug_structure() for id '1234'
http://localhost:3000/mimeview/method/debug_structure/1234/

Defaults to false (0).

SEE ALSO

Email::MIME

TODO

* Define a View API and write proper View classes
* Document the controller actions
* Write tests

AUTHOR

Henry Van Styn <vanstyn@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by IntelliTree Solutions llc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.