Email-MIME
view release on metacpan or search on metacpan
1.929 2015-02-17 09:31:35-05:00 America/New_York
- try not to lose unrecognized content-type parameters
- avoid copying the body content when not needed during construction
1.928 2014-12-15 21:47:49-05:00 America/New_York
- when converting from single part to multipart, drop
Content-Transfer-Encoding and Content-Type's charset property
- update subparts in walk_parts if stringification changes
1.927 2014-12-04 10:19:58-05:00 America/New_York
- add header_str_pairs; like header_pairs, but decoded
- remove Email:MIME::Creator from synopsis
1.926 2014-01-28 23:28:41-05:00 America/New_York
- improve EOL processing with quoted-printable (thanks, Tomohiro
Hosaka!)
- avoid uninitialized warnings [rt.cpan.org #91707]
1.925 2013-11-08 07:01:03 America/New_York
- improve reliability of mail reconstruction during walk_parts (thanks,
Tomohiro Hosaka!)
add better support for Unicode with body_str, header_str_set, etc.
1.863 2009-01-30
no code changes
add strangely missing copyright information
1.862 2009-01-22
add repository location metadata
always require Encode, never MIME::Words; this means that using
Email::MIME on pre-5.008 will be difficult, if not impossible
if a header can't be decoded, fall back to the raw header
move decoding methods to Email::MIME::Header, add header_raw
1.861 2007-11-05
added perl-minver.t -- Email::MIME requires perl >= 5.006
we now require Email::Simple 2.003
1.860 2007-07-13
tentative tweak to tests and C-T-E handling for charset
probably needs more research, testing, and fixing
lib/Email/MIME.pm view on Meta::CPAN
#pod
#pod B<Wait!> Before you read this, maybe you just need L<Email::Stuffer>, which is
#pod a much easier-to-use tool for building simple email messages that might have
#pod attachments or both plain text and HTML. If that doesn't do it for you, then
#pod by all means keep reading.
#pod
#pod use Email::MIME;
#pod my $parsed = Email::MIME->new($message);
#pod
#pod my @parts = $parsed->parts; # These will be Email::MIME objects, too.
#pod my $decoded = $parsed->body;
#pod my $non_decoded = $parsed->body_raw;
#pod
#pod my $content_type = $parsed->content_type;
#pod
#pod ...or...
#pod
#pod use Email::MIME;
#pod use IO::All;
#pod
#pod # multipart message
#pod my @parts = (
lib/Email/MIME.pm view on Meta::CPAN
#pod ],
#pod );
#pod
#pod print $email->as_string;
#pod
#pod =head1 DESCRIPTION
#pod
#pod This is an extension of the L<Email::Simple> module, to handle MIME
#pod encoded messages. It takes a message as a string, splits it up into its
#pod constituent parts, and allows you access to various parts of the
#pod message. Headers are decoded from MIME encoding.
#pod
#pod =head1 METHODS
#pod
#pod Please see L<Email::Simple> for the base set of methods. It won't take
#pod very long. Added to that, you have:
#pod
#pod =cut
our $CREATOR = 'Email::MIME::Creator';
lib/Email/MIME.pm view on Meta::CPAN
B<Wait!> Before you read this, maybe you just need L<Email::Stuffer>, which is
a much easier-to-use tool for building simple email messages that might have
attachments or both plain text and HTML. If that doesn't do it for you, then
by all means keep reading.
use Email::MIME;
my $parsed = Email::MIME->new($message);
my @parts = $parsed->parts; # These will be Email::MIME objects, too.
my $decoded = $parsed->body;
my $non_decoded = $parsed->body_raw;
my $content_type = $parsed->content_type;
...or...
use Email::MIME;
use IO::All;
# multipart message
my @parts = (
lib/Email/MIME.pm view on Meta::CPAN
],
);
print $email->as_string;
=head1 DESCRIPTION
This is an extension of the L<Email::Simple> module, to handle MIME
encoded messages. It takes a message as a string, splits it up into its
constituent parts, and allows you access to various parts of the
message. Headers are decoded from MIME encoding.
=head1 PERL VERSION
This library should run on perls released even a long time ago. It should
work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the
minimum required version will not be increased. The version may be increased
for any reason, and there is no promise that patches will be accepted to
lower the minimum required perl.
lib/Email/MIME.pm view on Meta::CPAN
as MIME encoded-words if they contain any control or 8-bit characters.
Alternatively, values can be objects with C<as_mime_string> method. Same as in
method C<create>.
=head2 header_str_pairs
my @pairs = $email->header_str_pairs;
This method behaves like C<header_raw_pairs>, returning a list of field
name/value pairs, but the values have been decoded to character strings, when
possible.
=head2 header_as_obj
my $first_obj = $email->header_as_obj($field);
my $nth_obj = $email->header_as_obj($field, $index);
my @all_objs = $email->header_as_obj($field);
my $nth_obj_of_class = $email->header_as_obj($field, $index, $class);
my @all_objs_of_class = $email->header_as_obj($field, undef, $class);
lib/Email/MIME.pm view on Meta::CPAN
#pod as MIME encoded-words if they contain any control or 8-bit characters.
#pod
#pod Alternatively, values can be objects with C<as_mime_string> method. Same as in
#pod method C<create>.
#pod
#pod =method header_str_pairs
#pod
#pod my @pairs = $email->header_str_pairs;
#pod
#pod This method behaves like C<header_raw_pairs>, returning a list of field
#pod name/value pairs, but the values have been decoded to character strings, when
#pod possible.
#pod
#pod =method header_as_obj
#pod
#pod my $first_obj = $email->header_as_obj($field);
#pod my $nth_obj = $email->header_as_obj($field, $index);
#pod my @all_objs = $email->header_as_obj($field);
#pod
#pod my $nth_obj_of_class = $email->header_as_obj($field, $index, $class);
#pod my @all_objs_of_class = $email->header_as_obj($field, undef, $class);
t/charset.t view on Meta::CPAN
like(
$email->header('Content-type'),
qr/utf-8/i,
"we don't kill the charset on single 'parts' arg",
);
like(
$email->body_str,
qr/\xFF/,
"...and the decoded body still has U+00FF in it",
);
ok(1);
done_testing;
t/header-addresslist.t view on Meta::CPAN
use_ok('Email::MIME');
use_ok('Email::MIME::Header::AddressList');
}
{
my $email = Email::MIME->new('To: =?US-ASCII?Q?MIME=3A=3B?=: =?US-ASCII?Q?Winston=3A_Smith?= <winston.smith@recdep.minitrue>, =?US-ASCII?Q?Julia=3A=3B_?= <julia@ficdep.minitrue>' . "\r\n\r\n");
my $str = $email->header_str('To');
my $obj = $email->header_as_obj('To');
my @addr = $obj->addresses();
my @grps = $obj->groups();
is($str, '"MIME:;": "Winston: Smith" <winston.smith@recdep.minitrue>, "Julia:; " <julia@ficdep.minitrue>;'); # See that decoded From header string is now quoted, so is unambiguous
is($addr[0]->phrase, 'Winston: Smith');
is($addr[0]->address, 'winston.smith@recdep.minitrue');
is($addr[1]->phrase, 'Julia:; ');
is($addr[1]->address, 'julia@ficdep.minitrue');
is($grps[0], 'MIME:;');
is($grps[1]->[0]->phrase, 'Winston: Smith');
is($grps[1]->[0]->address, 'winston.smith@recdep.minitrue');
is($grps[1]->[1]->phrase, 'Julia:; ');
is($grps[1]->[1]->address, 'julia@ficdep.minitrue');
}
Part one, part one!
__MESSAGE__
Content-Transfer-Encoding: base64
UGFydCB0d28sIHBhcnQgdHdvIQo=
__MESSAGE2__
is scalar($email->parts), 2, 'two parts';
is +($email->parts)[1]->body, qq[Part two, part two!\n], 'part two decoded';
$email->parts_add([ $email->parts ]);
is scalar($email->parts), 4, 'four parts';
is +($email->parts)[1]->body, qq[Part two, part two!\n], 'part two decoded again';
is +($email->parts)[3]->body, qq[Part two, part two!\n], 'part four decoded';
$email->walk_parts(sub {
my $part = shift;
isa_ok $part, 'Email::MIME';
$part->encoding_set('base64') if $part->parts <= 1;
$part->body_set( "foo\nbar" ) if $part->parts <= 1;
});
$email->walk_parts(sub {
( run in 0.315 second using v1.01-cache-2.11-cpan-5f2e87ce722 )