NAME

GT::Mail::Parse - MIME Parse


SYNOPSIS

    use GT::Mail::Parse
    
    my $parser = new GT::Mail::Parse (
        naming  => \&name_files,
        in_file => '/path/to/file.eml',
        debug   => 1
    );
    my $top = $parser->parse or die $GT::Mail::Parse::error;
    - or -
    my $parser = new GT::Mail::Parse;
    
    open FH, '/path/to/file.eml' or die $!;
    my $top = $parser->parse (
        naming  => \&name_files,
        handle  => \*FH,
        debug   => 1
    ) or die $GT::Mail::Parse::error;
    close FH;
    - or -
    my $parser = new GT::Mail::Parse;
    my $top_head = $parser->parse_head (
        naming  => \&name_files,
        in_file => '/path/to/file.eml',
        debug   => 1
    ) or die $GT::Mail::Parse::error;


DESCRIPTION

GT::Mail::Parse is a 100% rfc822 email MIME parser that supports unlimited nested levels of MIME. Emails are parsed into the GT::Mail::Parts manpage objects. Each part knows where it's body is and each part contains it's sub parts. See the GT::Mail::Parts manpage for details on parts methods.

new - Constructor method

This is the constructor method to get a GT::Mail::Parse object, which you need to access all the methods (there are no Class methods). new() takes a hash or hash ref as it's arguments. Each key has an accessor method by the same name except debug, which can only be set by passing debug to new(), parse() or parse_head().

debug
Sets the debug level for this insance of the class.

naming
Specify a code reference to use as a naming convention for each part of the email being parsed. This is useful to keep file IO down when you want the emails seperated into each part as a file. If this is not specified GT::Mail::Parse uses a default naming, which is to start at one and incriment that number for each attachment. The attachments would go in the current working directory.

in_file
Specify the path to the file that contains the email to be parsed. One of in_file and handle must be specified.

handle
Specify the file handle or IO stream that contains the email to be parsed.

attach_rfc822
By default, the parser will decode any embeded emails, and flatten out all the parts. If you prefer to leave embeded emails unparsed, pass in 1 to this option and the parser will treat it as an attachment.

parse - Parse an email

Instance method. Parses the email specified by either in_file or handle. Returns the top level the GT::Mail::Parts manpage object. Any additional parameters passed in are treated the same as if they were passed to the constuctor.

parse_head - Parse just the header of the email

Instance method. This method is exactly the same as parse except only the top level header is parsed and it's part object returned. This is useful to keep overhead down if you only need to know about the header of the email.

size - Get the size

Instance method. Returns the total size in bytes of the parsed unencoded email. This method will return undef if no email has been parsed.

all_parts - Get all parts

Instance method. Returns all the parts in the parsed email. This is a flatened list of the objects. Somewhat similar to what MIME::Tools does. All the parts still contain their sub parts.


COPYRIGHT

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


VERSION

Revision: $Id: Parse.pm,v 1.79 2004/10/23 02:16:39 brewt Exp $