The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mail::Qmail::Queue::Receive::Body - Receive message body when emulating qmail-queue

SYNOPSIS

  use Mail::Qmail::Queue::Receive::Body;

  my $qq_body = Mail::Qmail::Queue::Receive::Body->new
    or die "Couldn't get qmail-queue body\n"

  print "Message body: ",$qq_body->body,"\n";

  my $fh = $qq_body->body_fh
    or die "Error getting body handle: $!\n";
  while (<$fh>) {
    s/perl/Pathologically Eclectic Rubbish Lister/gi;
    print;
  }
  $fh->close
    or die "Error closing message: $!\n";

DESCRIPTION

Mail::Qmail::Queue::Receive::Body is designed for use in qmail-queue emulation. This is a way of modifying the behavior of qmail by replacing its queueing mechanism with your own program, which may modify or reject the message, then call the real qmail-queue program to queue the message. This is commonly done with Bruce Guenter's QMAILQUEUE patch (http://www.qmail.org/top.html#qmailqueue), also included in netqmail (http://www.qmail.org/netqmail/). This patch lets you override the standard qmail-queue program by setting the environment variable QMAILQUEUE. It can also be done by renaming the original qmail-queue, installing your script in its place, and having your script call the renamed qmail-queue to inject the message.

For a simplified interface, see Mail::Qmail::Queue::Message. To read the message envelope, see Mail::Qmail::Queue::Receive::Envelope. To re-inject the message, see Mail::Qmail::Queue::Send.

Note that the specifications for qmail-queue's interface require that the message be read before the envelope.

The constructor and methods of this class will die if they encounter a serious error. If you would prefer different behavior, use eval to catch these and handle them as exceptions.

CONSTRUCTOR

new ( %options )

Creates a new qmail-queue message body reader, but does not start reading it.

Available options are:

FileHandle

Read the body from the specified file handle, instead of the default of file desriptor 0.

METHODS

body_fh( )

Returns a filehandle from which the body can be read.

close( )

Closes the filehandle with the message body, and returns the result of the close.

body( )

Returns the entire body as a string, then closes the filehandle. Note that this can consume a lot of memory for a very large message; reading it from the handle returned by the body_fh method will be more efficient.

SEE ALSO

qmail-queue(8), Mail::Qmail::Queue::Message, Mail::Qmail::Queue::Receive::Envelope, Mail::Qmail::Queue::Send.

COPYRIGHT

Copyright 2006 Scott Gifford.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.