TipJar::MTA::queue - send e-mail via TipJar::MTA
use TipJar::MTA::queue '/var/MTAspool'; # sets $TipJar::MTA::queue::basedir my $m = new TipJar::MTA::queue; $m->return_address('email@example.com'); $m->recipient('firstname.lastname@example.org'); # must pass sanity check $m->data(<<EOF); # include all headers From: my name <iamthesender\@mydomain.tld> To: your name <email@example.com> Subject: this is a test from me to you
This was sent out via the TipJar::MTA outbound SMTP system! EOF $m->enqueue(); # a TipJar::MTA daemon on /var/MTAspool # will attempt delivery presently. $m # is cleared for reuse. $m->return_address('firstname.lastname@example.org'); $m->recipient(@list_members); # will expand array refs ...
TipJar::MTA::queue creates messages in the outgoing queue of a TipJar::MTA daemon. It is provided for use within other software that composes the mails. It does not provide any header lines or MIME formatting etc. -- you have to get that elsewhere and use the provided interface to add the data to the object.
this package variable holds the base directory of the TipJar::MTA queue; (see)
returns a blessed object reference. Many of these can coexist without interfering with each other.
takes a scalar which must pass a sanity test which is probably not loose enough, will croak when the return_address is not sane
takes one or more addresses or array references. Trusts that the addresses it is given are valid. Invalid addresses will stop processing and get included as weird header lines. Array references are not expanded until
Appends its argument(s) to the message data block.
Constructs a new message file according to the TipJar::MTA new message format, and clears the object for reuse.
it would be nice to insert more headers into the message. mail::Sendmail looks like the place to from which to lift features. OTOH, the clarity of only allowing return address, recipient list, and data is good; perhaps using another module to compose header lines and building the data block before passing it to
$m->data() is the way to go. So I might create and publish a TipJar::MTA::compose module which will rely on the TipJar::MTA::queue interface to post its composed messages.
The object is at this time an array-based object originally facilitated using TipJar::fields, but now it just has the field names written into it as constant functions.
This module (and the TipJar::MTA daemon) rely on flock locking for data corruption control, so it is not reccommended for use on a shared volume (such as NFS) unless your locking daemons are cooperative and robust.
Original version, April 2003
test script now sends the author two e-mails, in concert with the test script of the TipJar::MTA module. See the test script for example of a date header generator.
david nicol <email@example.com>
CPAN has myriad modules to help with composing and sending e-mail.
None of them have the same interface.