Mail::Qmail::Queue::Send - Send a message to a program implementing the qmail-queue interface
use Mail::Qmail::Queue::Send; my $qq = Mail::Qmail::Queue::Send->new() or die "Couldn't create qmail-queue sender: $!\n"; $qq_send->body("Test message\n") or die "Couldn't write body: $!\n"; $qq_send->from('firstname.lastname@example.org') or die "Couldn't write envelope from: $!\n"; $qq_send->to('GIFF@cpan.org') or die "Couldn't write envelope to #1: $!\n"; $qq_send->to('email@example.com') or die "Couldn't write envelope to #2: $!\n"; $qq_send->envelope_done() or die "Couldn't finish writing envelope: $!\n"; $qq_send->wait_exitstatus() == 0 or die "Error sending message: exit status $?\n";
Note that the qmail-queue(8) specifications require that the body be read first, then the envelope.
This module sends a message to a program implementing the qmail-queue(8) protocol. You must send the body first, then the envelope.
- new ( %options )
Creates a new qmail-queue sender. Executes
qmail-queueor the equivalent, and sets up the file descriptors to prepare to talk to it. If a
QmailQueueoption is given, that will be used as the path to the
qmail-queueprogram. Otherwise, the contents of the environment variable
QMAILQUEUEwill be used; if that is unset,
/var/qmail/bin/qmail-queueis the default.
Available options are:
Specifies the path to the program that will handle the message.
Do not open up file descriptor 1 to
qmail-queue's envelope reader; instead the current process's file descriptor 1 will be connected to it. This is useful if you are writing a filter to change the body, but want to leave the envelope alone.
Do not open up file descriptor 0 to
qmail-queue's body reader; instead the current process's file descriptor 0 will be connected to it. This is useful if you are writing a filter to change the envelope, but want to leave the body alone.
- send ( $body, $from, @to )
Sends a complete message, and returns the exit status of the
- body_fh ( )
Retrieves a Perl filehandle to which the message body can be written.
- body_close ( )
Close the body filehandle. You must use this when you're done sending the body filehandle, to indicate to the
qmail-queueprogram that you're done, and to tell this module that it's ready to accept the envelope.
- body ( @body )
Send the provided string or strings as the complete body of the message, closing the filehandle after sending it.
If you are working with a very large message, it may be more efficient to write the body in smaller pieces to the filehandle returned by
- from ( $from )
Send the provided email address as the envelope from. You must send the body first.
- to ( @to )
Send the provided email address or addresses as the envelope to. You must send the body and the envelope from first.
- envelope_done ( )
Indicate that you have sent all of the envelope, and are now done. The filehandle will be closed, and
qmail-queuewill probably begin processing the message.
- put_envelope_entry ( @entries )
Send the provided envelope entries. They must be properly formatted entries, or else they will confuse the called
qmail-queueprogram. The null character will be inserted between the entries by this method, and you should not set it.
Note that if you use this method instead of
from, you cannot use the
tomethod, because this module won't know that you've already sent an envelope from.
Mail::Qmail::Queue::Receive::Envelope's read_envelope_string method will return strings that can be passed to this method.
- envelope_write ( @str )
Send the provided string or strings directly to the
qmail-queueenvelope filehandle. This requires a knowledge of the qmail-queue(8) protocol.
Retrieve a Perl filehandle to which the message envelope can be written. Using this filehandle requires knowledge of the envelope format; see qmail-queue(8) for details.
- wait_exitstatus ( )
Wait for the
qmail-queueprogram to finish, and return its exit status. If the program is killed by a signal, QQ_EXIT_BUG will be returned.
- wait ( )
Wait for the
qmail-queueprogram to finish, and return the value from
Copyright 2006 Scott Gifford.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.