1Email::MIME(3) User Contributed Perl Documentation Email::MIME(3)
2
3
4
6 Email::MIME - Easy MIME message parsing.
7
9 version 1.863
10
12 use Email::MIME;
13 my $parsed = Email::MIME->new($message);
14
15 my @parts = $parsed->parts; # These will be Email::MIME objects, too.
16 my $decoded = $parsed->body;
17 my $non_decoded = $parsed->body_raw;
18
19 my $content_type = $parsed->content_type;
20
22 This is an extension of the Email::Simple module, to handle MIME
23 encoded messages. It takes a message as a string, splits it up into its
24 constituent parts, and allows you access to various parts of the
25 message. Headers are decoded from MIME encoding.
26
28 This is an alpha release, designed to stimulate discussion on the API,
29 which may change in future releases. Please send me comments about any
30 features you think "Email::MIME" should have. Note that I expect most
31 things to be driven by subclassing and mix-ins.
32
34 Please see Email::Simple for the base set of methods. It won't take
35 very long. Added to that, you have:
36
37 parts
38 This returns a list of "Email::MIME" objects reflecting the parts of
39 the message. If it's a single-part message, you get the original object
40 back.
41
42 In scalar context, this method returns the number of parts.
43
44 subparts
45 This returns a list of "Email::MIME" objects reflecting the parts of
46 the message. If it's a single-part message, this method returns an
47 empty list.
48
49 In scalar context, this method returns the number of subparts.
50
51 body
52 This decodes and returns the body of the object. For top-level objects
53 in multi-part messages, this is highly likely to be something like
54 "This is a multi-part message in MIME format."
55
56 body_raw
57 This returns the body of the object, but doesn't decode the transfer
58 encoding.
59
60 decode_hook
61 This method is called before the Email::MIME::Encodings "decode"
62 method, to decode the body of non-binary messages (or binary messages,
63 if the "force_decode_hook" method returns true). By default, this
64 method does nothing, but subclasses may define behavior.
65
66 This method could be used to implement the decryption of content in
67 secure email, for example.
68
69 content_type
70 This is a shortcut for access to the content type header.
71
72 filename
73 This provides the suggested filename for the attachment part. Normally
74 it will return the filename from the headers, but if "filename" is
75 passed a true parameter, it will generate an appropriate "stable"
76 filename if one is not found in the MIME headers.
77
78 invent_filename
79 my $filename = Email::MIME->invent_filename($content_type);
80
81 This routine is used by "filename" to generate filenames for attached
82 files. It will attempt to choose a reasonable extension, falling back
83 to dat.
84
85 debug_structure
86 my $description = $email->debug_structure;
87
88 This method returns a string that describes the structure of the MIME
89 entity. For example:
90
91 + multipart/alternative; boundary="=_NextPart_2"; charset="BIG-5"
92 + text/plain
93 + text/html
94
96 All of the Email::MIME-specific guts should move to a single entry on
97 the object's guts. This will require changes to both Email::MIME and
98 Email::MIME::Modifier, sadly.
99
101 Email::Simple, Email::MIME::Modifier, Email::MIME::Creator.
102
104 This module is maintained by the Perl Email Project
105
106 <http://emailproject.perl.org/wiki/Email::MIME>
107
109 Casey West, "casey@geeknest.com"
110
111 Simon Cozens, "simon@cpan.org" (retired)
112
113 This software is copyright (c) 2004 by Simon Cozens.
114
115 This is free software; you can redistribute it and/or modify it under
116 the same terms as perl itself.
117
119 This module was generously sponsored by Best Practical
120 (http://www.bestpractical.com/) and Pete Sergeant.
121
122
123
124perl v5.12.0 2009-01-30 Email::MIME(3)