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

use Email::MIME;
use Email::MIME::Modifier;
my $email = Email::MIME->new( join "", <> );
remove_attachments($email);
sub remove_attachments {
my $email = shift;
my @keep;
foreach my $part ( $email->parts ) {
push @keep, $part
unless $part->header('Content-Disposition') =~ /^attachment/;
remove_attachments($part)
if $part->content_type =~ /^(?:multipart|message)/;
}
$email->parts_set( \@keep );
}

Provides a number of useful methods for manipulating MIME messages.
These method are declared in the Email::MIME namespace, and are used with Email::MIME objects.
$email->content_type_set( 'text/html' );
Change the content type. All Content-Type header attributes will remain in tact.
$email->charset_set( 'utf8' ); $email->name_set( 'some_filename.txt' ); $email->format_set( 'flowed' ); $email->boundary_set( undef ); # remove the boundary
These four methods modify common Content-Type attributes. If set to undef, the attribute is removed. All other Content-Type header information is preserved when modifying an attribute.
$email->encoding_set( 'base64' ); $email->encoding_set( 'quoted-printable' ); $email->encoding_set( '8bit' );
Convert the message body and alter the Content-Transfer-Encoding header using this method. Your message body, the output of the body() method, will remain the same. The raw body, output with the body_raw() method, will be changed to reflect the new encoding.
$email->body_set( $unencoded_body_string );
This method will encode the new body you send using the encoding specified in the Content-Transfer-Encoding header, then set the body to the new encoded body.
This method overrides the default body_set() method.
$email->disposition_set( 'attachment' );
Alter the Content-Disposition of a message. All header attributes will remain in tact.
$email->filename_set( 'boo.pdf' );
Sets the filename attribute in the Content-Disposition header. All other header information is preserved when setting this attribute.
$email->parts_set( \@new_parts );
Replaces the parts for an object. Accepts a reference to a list of Email::MIME objects, representing the new parts. If this message was originally a single part, the Content-Type header will be changed to multipart/mixed, and given a new boundary attribute.

Email::Simple, Email::MIME, Email::MIME::Encodings, Email::MIME::ContentType, perl.

Casey West, <casey@geeknest.com>.

Copyright (c) 2004 Casey West. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.