NAME

Mail::Qmail::Queue::Message - Send and/or receive a complete qmail-queue message.

SYNOPSIS

  use Mail::Qmail::Queue::Send;

  # Read the message
  my $msg = Mail::Qmail::Queue::Message->receive()
    or die "Invalid message\n";

  # Change the from
  my $fr = $msg->from_ref();
  $$fr =~ s/\$/-\@[]/;   # Enable VERPs

  # Change the to
  my $to = $msg->to_ref();
  push(@$to,'GIFF@cpan.org');

  # Change the body
  my $br = $msg->body_ref();
  $$br =~ s/perl/Pathologically Eclectic Rubbish Lister/ig;

  # Now send
  $msg->send() == 0
    or die "Couldn't send message: Exit status $?\n";

DESCRIPTION

This module handles mail messages sent and/or received by a program implementing the qmail-queue interface.

You can create a message by providing the body and envelope to the constructor new, or from the file descriptors provided by the qmail-queue interface with the constructor receive.

You can then modify the message and its envelope, if desired, by getting references to the various parts and modifying their referents.

Finally, you can send the message with the send method.

CONSTRUCTORS

new ( $body, $from, @to )

Create a new mail message with the provided body, from, and to.

receive ( %options )

Receive a message with the qmail-queue protocol.

This will read the entire message into memory; for very large messages and/or a lot of recipients, see Mail::Qmail::Queue::Send, Mail::Qmail::Queue::Receive::Envelope, and Mail::Qmail::Queue::Receive::Body.

Available options are:

EnvelopeFileHandle

Read the envelope from the provided FileHandle, instead of the default.

BodyFileHandle

Read the body from the provided FileHandle, instead of the default.

METHODS

send ( %options )

Send the message using the qmail-queue protocol. The exit status from the qmail-queue program will be returned, so 0 indicates success. Valid options are the options for Mail::Qmail::Queue::Send->new.

from ( )

Get the from part of the envelope.

from_ref ( )

Get a reference to the from part of the envelope. By operating on this reference, you can change the value stored in this object.

to ( )

Get all to parts of the envelope.

to_ref ( )

Get a reference to the list of envelope to items. By modifying this list or its contents, you can change the values within this object.

body ( )

Get the body of the message.

body_ref ( )

Get a reference to the body of the message. By modifying this reference, you can change the value of the body within this object.

SEE ALSO

qmail-queue(8), Mail::Qmail::Queue::Receive::Envelope, Mail::Qmail::Queue::Receive::Body, 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.