HTML-FromMail

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

         }
      },
      "runtime" : {
         "requires" : {
            "HTML::FromText" : "2.03",
            "Log::Report" : "1.42",
            "Mail::Box" : "4.00",
            "OODoc::Template" : "0.19"
         },
         "x_optional" : {
            "Image::Magick" : "5.0",
            "Template::Magic" : "1.02"
         }
      },
      "test" : {
         "requires" : {
            "Test::More" : "1",
            "Test::Pod" : "1"
         }
      }
   },

Makefile.PL  view on Meta::CPAN

my %requires = (
	'Mail::Box'        => '4.00',
	'HTML::FromText'   => '2.03',
	'OODoc::Template'  => '0.19',  # default template system
	'Log::Report'      => '1.42',
);

# See README.md for uses
my %optional = (
	'Template::Magic'  => '1.02',
	'Image::Magick'    => '5.0',
);

WriteMakefile
	NAME       => 'HTML::FromMail',
	VERSION    => $version,
	AUTHOR     => 'Mark Overmeer <markov@cpan.org>',
	ABSTRACT   => 'Convert E-mail into HTML',
	LICENSE    => 'perl_5',

	META_MERGE => {

README.md  view on Meta::CPAN

On github, you can find the processed version for each release.  But the
better source is CPAN; to get it installed simply run:

```sh
   cpan -i HTML::From-Mail
```

You may wish to install with following extras:

```sh
   cpan -i Template::Magic Image::Magick HTML::From-Mail
```

### optional Template::Magic

Required if you want to use the Template::Magic formatter, which is not
required to run the examples.

### optional Image::Magick

When messages contain images, these images can be shown as small
previews.  This is done with Image::Magick, which is quite hard to
install (IMHO).  So if you want to give it a try answer yes.

When you do not install Image::Magick, some examples will not work.  But
you can always install it later.

## Development &rarr; Release

Important to know, is that I use an extension on POD to write the manuals.
The "raw" unprocessed version is visible on GitHub.  It will run without
problems, but does not contain manual-pages.

Releases to CPAN are different: "raw" documentation gets removed from
the code and translated into real POD and clean HTML.  This reformatting

lib/HTML/FromMail/Default/Previewers.pm  view on Meta::CPAN


use Log::Report 'html-frommail';

use File::Basename qw/basename dirname/;

#--------------------

our @previewers = (
	'text/plain' => \&previewText,
	'text/html'  => \&previewHtml,
	'image'      => \&previewImage,  # added when Image::Magick is installed
);


sub previewText($$$$$)
{	my ($page, $message, $part, $attach, $args) = @_;

	my $decoded  = $attach->{decoded}->string;
	for($decoded)
	{	s/^\s+//;
		s/\s+/ /gs;     # lists of blanks

lib/HTML/FromMail/Default/Previewers.pm  view on Meta::CPAN

	substr($decoded, $max) = '' if length $decoded > $max;

	 +{	%$attach,
		image => '',            # this is not an image
		html  => { text => $decoded },
	  };
}


BEGIN
{	eval   { require Image::Magick };
	if($@) { warning __x"Image::Magick not installed." }
	else   { push @previewers, image => \&previewImage }
}

sub previewImage($$$$$)
{	my ($page, $message, $part, $attach, $args) = @_;

	my $filename = $attach->{filename};
	my $magick   = Image::Magick->new;
	my $error    = $magick->Read($filename);
	length $error
		and error __x"cannot read image from {fn}: {error}", fn => $filename, error => $error;

	my %image;
	my ($srcw, $srch) = @image{ qw/width height/ } = $magick->Get( qw/width height/ );

	my $base     = basename $filename;
	$base        =~ s/\.[^.]+$//;

lib/HTML/FromMail/Default/Previewers.pod  view on Meta::CPAN

        </cite></blockquote>
     <!--{/html}-->
  <!--{/preview}-->

=back

=head1 DIAGNOSTICS

=over 4

=item Warning: Image::Magick not installed.

Cast by C<previewImage()>

=item Error: cannot read image from $fn: $error

Cast by C<previewImage()>

=item Error: cannot resize image from $fn: $error

Cast by C<previewImage()>



( run in 1.105 second using v1.01-cache-2.11-cpan-39bf76dae61 )