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