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.441
10
11         $Id: /my/pep/Email-MIME-Modifier/trunk/lib/Email/MIME/Modifier.pm 28539 2006-11-28T01:49:38.991940Z rjbs  $
12

SYNOPSIS

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

DESCRIPTION

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

SEE ALSO

125       Email::Simple, Email::MIME, Email::MIME::Encodings, Email::MIME::Con‐
126       tentType, perl.
127

PERL EMAIL PROJECT

129       This module is maintained by the Perl Email Project
130
131       <http://emailproject.perl.org/wiki/Email::MIME>
132

AUTHOR

134       Casey West, <casey@geeknest.com>.
135
137         Copyright (c) 2004 Casey West.  All rights reserved.
138         This module is free software; you can redistribute it and/or modify it
139         under the same terms as Perl itself.
140
141
142
143perl v5.8.8                       2006-11-27          Email::MIME::Modifier(3)
Impressum