Email-MIME

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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!)

Changes  view on Meta::CPAN

211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
          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

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#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

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#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

948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
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

1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
      ],
  );
 
  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

1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
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

1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
#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

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  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');
}

t/parts.t  view on Meta::CPAN

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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.663 second using v1.01-cache-2.11-cpan-5f2e87ce722 )