NAME

Mail::IMAPClient::BodyStructure - Perl extension to Mail::IMAPClient to facilitate the parsing of server responses to the FETCH BODYSTRUCTURE IMAP client command.

SYNOPSIS

  use Mail::IMAPClient::BodyStructure;
  use Mail::IMAPClient;

  my $imap = Mail::IMAPClient->new(Server=>$serv,User=>$usr,Password=>$pwd);
  $imap->select("INBOX") or die "cannot select the inbox for $usr: $@\n";

  my @recent = $imap->search("recent");

  foreach my $new (@recent) {

	my $struct = Mail::IMAPClient::BodyStructure->new($imap->fetch($new,"bodystructure"));

	print	"Msg $new (Content-type: ",$struct->bodytype,"/",$struct->bodysubtype,
        	") contains these parts:\n\t",join("\n\t",$struct->parts),"\n\n";


  }


  

DESCRIPTION

This extension will parse the result of an IMAP FETCH BODYSTRUCTURE command into a perl data structure. It also provides helper methods that will help you pull information out of the data structure.

Use of this extension requires Parse::RecDescent. If you don't have Parse::RecDescent then you must either get it or refrain from using this module.

EXPORT

There are no restrictions on exporting this module out of the US. (Oh, did you want to know what variables are exported by default or exportable upon request? There aren't any.)

Class Methods

The following class method is available:

new

This class method is the constructor method for instantiating new Mail::IMAPClient::BodyStructure objects. The new method accepts one argument, a string containing a server response to a FETCH BODYSTRUCTURE directive. Only one message's body structure should be described in this string, although that message may contain an arbitrary number of parts.

If you know the messages sequence number or unique ID (UID) but haven't got its body structure, and you want to get the body structure and parse it into a Mail::IMAPClient::BodyStructure object, then you might as well save yourself some work and use Mail::IMAPClient's get_bodystructure method, which accepts a message sequence number (or UID if Uid is true) and returns a Mail::IMAPClient::BodyStructure object. It's functionally equivalent to issuing the FETCH BODYSTRUCTURE IMAP client command and then passing the results to Mail::IMAPClient::BodyStructure's new method but it does those things in one simple method call.

Object Methods

The following object methods are available:

bodytype

The bodytype object method requires no arguments. It returns the bodytype for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodysubtype

The bodysubtype object method requires no arguments. It returns the bodysubtype for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodyparms

The bodyparms object method requires no arguments. It returns the bodyparms for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodydisp

The bodydisp object method requires no arguments. It returns the bodydisp for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodyid

The bodyid object method requires no arguments. It returns the bodyid for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodydesc

The bodydesc object method requires no arguments. It returns the bodydesc for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodyenc

The bodyenc object method requires no arguments. It returns the bodyenc for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodysize

The bodysize object method requires no arguments. It returns the bodysize for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodylang

The bodylang object method requires no arguments. It returns the bodylang for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

bodystructure

The bodystructure object method requires no arguments. It returns the bodystructure for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

envelopestruct

The envelopestruct object method requires no arguments. It returns the envelopestruct for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

textlines

The textlines object method requires no arguments. It returns the textlines for the message whose structure is described by the calling Mail::IMAPClient::Bodystructure object.

AUTHOR

David J. Kernen

SEE ALSO

perl(1), Mail::IMAPClient, and RFC2060.