Email-MIME-CreateHTML
view release on metacpan or search on metacpan
lib/Email/MIME/CreateHTML.pm view on Meta::CPAN
If no Date header is specified, one will be provided for you based on the
gmtime() of the local machine.
=item body =E<gt> I<scalar>
A scalar value holding the HTML message body.
=item body_attributes =E<gt> I<hash reference>
This is passed as the attributes parameter to the C<create> method (supplied by C<Email::MIME::Creator>) that creates the html part of the mail.
The body content-type will be set to C<text/html> unless it is overidden here.
=item embed =E<gt> I<boolean>
Attach relative images and other media to the message. This is enabled by default.
The module will attempt to embed objects defined by C<embed_elements>.
Note that this option only affects the parsing of the HTML and will not affect the C<objects> option.
The object's URI will be rewritten as a Content ID.
=item embed_elements =E<gt> I<reference to hash of hashes with boolean values>
lib/Email/MIME/CreateHTML/Resolver/LWP.pm view on Meta::CPAN
#Deduce MIME type and transfer encoding
my ($mimetype, $encoding);
if(defined $filename && length($filename)) {
TRACE("Using file extension to deduce MIME type and transfer encoding");
($mimetype, $encoding) = MIME::Types::by_suffix($filename);
} else {
$filename = 'index';
}
#If we have a content-type header we can make a more informed guess at MIME type
if ($response->header('content-type')) {
$mimetype = $response->header('content-type');
TRACE("Content Type header: $mimetype");
$mimetype = $1 if($mimetype =~ /(\S+);\s*charset=(.*)$/); #strip down to just a MIME type
}
#If all else fails then some conservative and general-purpose defaults are:
$mimetype ||= 'application/octet-stream';
$encoding ||= 'base64';
#Return values expected from a resource callback
return ($content, $filename, $mimetype, $encoding);
t/Email-MIME-CreateHTML.t view on Meta::CPAN
#######################################################
#
# Subroutines
#
#######################################################
sub test_mime {
my ($mime, $exp_content_type, $exp_body) = @_;
my $got_content_type = defined $mime ? $mime->content_type : undef;
ASSERT( defined $got_content_type && $got_content_type =~ /^$exp_content_type/i, "content-type: $got_content_type");
if ( defined $exp_body ) {
my $got_body;
$exp_body =~ s/\s+$//g;
$exp_body =~ s/(?<!\r)\n/\r\n/g; # MIME mandates CRLF line endings in all encodings except binary
if(defined $mime) {
$got_body = $mime->body;
# we don't care about trailing white space
( run in 1.334 second using v1.01-cache-2.11-cpan-524268b4103 )