1Email::MIME::Modifier(3U)ser Contributed Perl DocumentatiEomnail::MIME::Modifier(3)
2
3
4

NAME

6       Email::MIME::Modifier - Modify Email::MIME Objects Easily
7

VERSION

9       version 1.444
10

SYNOPSIS

12         use Email::MIME::Modifier;
13         my $email = Email::MIME->new( join "", <> );
14
15         remove_attachments($email);
16
17         sub remove_attachments {
18             my $email = shift;
19             my @keep;
20             foreach my $part ( $email->parts ) {
21                 push @keep, $part
22                   unless $part->header('Content-Disposition') =~ /^attachment/;
23                 remove_attachments($part)
24                   if $part->content_type =~ /^(?:multipart|message)/;
25             }
26             $email->parts_set( \@keep );
27         }
28

DESCRIPTION

30       Provides a number of useful methods for manipulating MIME messages.
31
32       These method are declared in the "Email::MIME" namespace, and are used
33       with "Email::MIME" objects.
34
35   Methods
36       content_type_set
37             $email->content_type_set( 'text/html' );
38
39           Change the content type. All "Content-Type" header attributes will
40           remain in tact.
41
42       charset_set
43       name_set
44       format_set
45       boundary_set
46             $email->charset_set( 'utf8' );
47             $email->name_set( 'some_filename.txt' );
48             $email->format_set( 'flowed' );
49             $email->boundary_set( undef ); # remove the boundary
50
51           These four methods modify common "Content-Type" attributes. If set
52           to "undef", the attribute is removed. All other "Content-Type"
53           header information is preserved when modifying an attribute.
54
55       encoding_set
56             $email->encoding_set( 'base64' );
57             $email->encoding_set( 'quoted-printable' );
58             $email->encoding_set( '8bit' );
59
60           Convert the message body and alter the "Content-Transfer-Encoding"
61           header using this method. Your message body, the output of the
62           "body()" method, will remain the same. The raw body, output with
63           the "body_raw()" method, will be changed to reflect the new
64           encoding.
65
66       body_set
67             $email->body_set( $unencoded_body_string );
68
69           This method will encode the new body you send using the encoding
70           specified in the "Content-Transfer-Encoding" header, then set the
71           body to the new encoded body.
72
73           This method overrides the default "body_set()" method.
74
75       disposition_set
76             $email->disposition_set( 'attachment' );
77
78           Alter the "Content-Disposition" of a message. All header attributes
79           will remain in tact.
80
81       filename_set
82             $email->filename_set( 'boo.pdf' );
83
84           Sets the filename attribute in the "Content-Disposition" header.
85           All other header information is preserved when setting this
86           attribute.
87
88       parts_set
89             $email->parts_set( \@new_parts );
90
91           Replaces the parts for an object. Accepts a reference to a list of
92           "Email::MIME" objects, representing the new parts. If this message
93           was originally a single part, the "Content-Type" header will be
94           changed to "multipart/mixed", and given a new boundary attribute.
95
96       parts_add
97             $email->parts_add( \@more_parts );
98
99           Adds MIME parts onto the current MIME part. This is a simple
100           extension of "parts_set" to make our lives easier. It accepts an
101           array reference of additional parts.
102
103       walk_parts
104             $email->walk_parts(sub {
105                 my $part = @_;
106                 return if $part->parts > 1; # multipart
107
108                 if ( $part->content_type =~ m[text/html] ) {
109                     my $body = $part->body;
110                     $body =~ s/<link [^>]+>//; # simple filter example
111                     $part->body_set( $body );
112                 }
113             });
114
115           Walks through all the MIME parts in a message and applies a
116           callback to each. Accepts a code reference as its only argument.
117           The code reference will be passed a single argument, the current
118           MIME part within the top-level MIME object. All changes will be
119           applied in place.
120

SEE ALSO

122       Email::Simple, Email::MIME, Email::MIME::Encodings,
123       Email::MIME::ContentType, perl.
124

PERL EMAIL PROJECT

126       This module is maintained by the Perl Email Project
127
128       <http://emailproject.perl.org/wiki/Email::MIME>
129

AUTHOR

131       Casey West, <casey@geeknest.com>.
132
134         Copyright (c) 2004 Casey West.  All rights reserved.
135         This module is free software; you can redistribute it and/or modify it
136         under the same terms as Perl itself.
137
138
139
140perl v5.12.0                      2009-04-30          Email::MIME::Modifier(3)
Impressum