NAME

GT::Mail::Message - Encapsolates an email message.


SYNOPSIS

    use GT::Mail::Message;
 
    # Get a GT::Mail::Message object from the parser
    use GT::Mail::Parse;
    my $parser = new GT::Mail::Parse( in_file => "myemail.eml" );
    my $message = $parser->parse;
    # Get the top level part
    my $root_part = $message->root_part;
    # Replace the first part with a new part
    $message->replace_part( $root_part, $message->new_part(
        to => 'scott@gossamer-threads.com',
        from => 'alex@gossamer-threads.com',
        'content-type' => 'text/plain',
        body_data => 'Hi Scott, how are you?!'
    );
    # Add a part at the end
    my $end_part = $message->new_part(
        'content-type' => 'image/gif',
        body_path      => 'myimage.jpg'
    );
    $message->add_part_end( $root_part, $end_part );
    # Move the first part in the top part to after the end part
    $message->move_part_after( $root_part->parts->[0], $end_part );
    # Print the mime message
    print $message->to_string;


DESCRIPTION

GT::Mail::Message encapsolates a mime message which consists of the GT::Mail::Parts manpage object. This module provides methods to change, move, remove, and access these parts.

Creating a new GT::Mail::Message object

Usually you will get a GT::Mail::Message object by call the parse method in the GT::Mail::Parse manpage.

    my $message = $parser->parse;

You may also call new on this class specifying the top level part and or a debug level.

    my $message = new GT::Mail::Message(
        root_part => $part,
        debug    => 1
    );

Creating a new Part

You can create a part by calling new on the GT::Mail::Parts manpage directly

    my $part = new GT::Mail::Parts;
    $part->set( 'content-type' => 'image/gif' );
    $part->body_path( 'myimage.gif' );

or you can call a method in this module to get a new part

    my $part = $message->new_part(
        'content-type' => 'image/gif',
        body_path      => 'myimage.gif'
    );

This method is a wraper on a combination of new() and some other supporting methods in the GT::Mail::Parts manpage such as body_path(). Anything that is not body_path, body_data, or body_handle is treated as header values.

Manipulating Parts

A MIME message is just a format for storing a tree structure. We provide tree-like methods to manipulate parts. All the method for manipulating parts take the part object(s) as arguments. We do this so you do not need to know how the tree is tracked internally.

Accessing Parts

More to come!


COPYRIGHT

Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved. http://www.gossamer-threads.com/


VERSION

Revision: $Id: Message.pm,v 1.14 2004/01/13 01:35:17 jagerman Exp $