Email-MIME
view release on metacpan or search on metacpan
1101111121131141151161171181191201211221231241251261271281291301.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!)
211212213214215216217218219220221222223224225226227228229230
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
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
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
27282930313233343536373839404142434445464748#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
104105106107108109110111112113114115116117118119120121122123#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
948949950951952953954955956957958959960961962963964965966967968969B<Wait!> Before you
read
this, maybe you just need L<Email::Stuffer>, which is
attachments or both plain text and HTML. If that doesn't
do
it
for
you, then
by all means keep reading.
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...
# multipart message
my
@parts
= (
lib/Email/MIME.pm view on Meta::CPAN
102510261027102810291030103110321033103410351036103710381039104010411042104310441045
],
);
->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
124512461247124812491250125112521253125412551256125712581259126012611262126312641265as 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
152115221523152415251526152715281529153015311532153315341535153615371538153915401541#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
242526272829303132333435363738like(
->header(
'Content-type'
),
qr/utf-8/
i,
"we don't kill the charset on single 'parts' arg"
,
);
like(
->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
111213141516171819202122232425262728293031
use_ok(
'Email::MIME'
);
use_ok(
'Email::MIME::Header::AddressList'
);
}
{
my
= 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
=
->header_str(
'To'
);
my
$obj
=
->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'
);
}
192021222324252627282930313233343536373839404142434445Part one, part one!
__MESSAGE__
Content-Transfer-Encoding: base64
UGFydCB0d28sIHBhcnQgdHdvIQo=
__MESSAGE2__
is
scalar
(
->parts), 2,
'two parts'
;
is +(
->parts)[1]->body,
qq[Part two, part two!\n]
,
'part two decoded'
;
->parts_add([
->parts ]);
is
scalar
(
->parts), 4,
'four parts'
;
is +(
->parts)[1]->body,
qq[Part two, part two!\n]
,
'part two decoded again'
;
is +(
->parts)[3]->body,
qq[Part two, part two!\n]
,
'part four decoded'
;
->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;
});
->walk_parts(
sub
{
( run in 0.663 second using v1.01-cache-2.11-cpan-5f2e87ce722 )