| Net-QMQP documentation | Contained in the Net-QMQP distribution. |
Net::QMQP - Quick Mail Queueing Protocol Client for qmail
use Net::QMQP;
$qmqp = Net::QMQP->new(host => 'qmqpserver',Timeout => 60);
$qmqp->sender('kobayasi@piano.gs');
$qmqp->recipients('miyagawa@bulknews.net');
$qmqp->message($mail_message);
$qmqp->queueing();
THIS IS ALPHA SOFTWARE AND NO TEST!
The Net::QMQP module implements a client interface to the QMQP protocol.
This is the constructor for a new Net::QMQP object.
OPTIONS are passed in a hash like fashion, using key and value pairs. Possible options are:
timeout - Maximum time, in seconds, to wait for a response from the QMQP server (default: 120)
debug - Enable debugging information (default: 0)
host - The name of the remote host to which a QMQP connection is required.(default: localhost)
port - The using port.
sender - The sender e-mail address
recipients - The recipients' address(es). (array reference or scalar)
message - The message body.
Queueing the mail to the QMQP server.
There are accessors. Example:
$obj->sender('kobayasi@piano.gs'); # sets the param.
$obj->recipients([qw( kobayasi@piano.gs miyagawa@bulknews.net )]);
Kobayasi Hiroyuki <kobayasi@piano.gs>
This library is free software; upi can redistribute it and/or modify it under the same terms as Perl itself.
IO::Socket::INET
| Net-QMQP documentation | Contained in the Net-QMQP distribution. |
package Net::QMQP; use strict; use vars qw($VERSION); use Carp; use IO::Socket; $VERSION = "0.01"; use base qw( Class::Accessor ); __PACKAGE__->mk_accessors( qw(sender recipients host message timeout port debug) ); sub new { my $self = shift; my $type = ref($self) || $self; my %args = @_; my $obj = $type->SUPER::new(\%args); $obj->{host} ||= 'localhost'; $obj->{timeout} ||= 120; $obj->{port} ||= 628; return $obj; } sub queueing { my $self = shift; my $buff = _netstring($self->message); $buff .= _netstring($self->sender); if( ref($self->recipients) eq 'ARRAY' ){ $buff .= join("",map{_netstring($_)}@{$self->recipients}); }else{ $buff .= _netstring($self->recipients); } $buff = _netstring($buff); my $sock = IO::Socket::INET->new(PeerAddr => $self->host, PeerPort => $self->port, Proto => 'tcp', Timeout => $self->timeout, ) or die($@); $sock->autoflush(1); carp($buff) if $self->debug; print $sock $buff; my $res = join("",<$sock>); close($sock); return $res; } sub _netstring { my $str = shift; return sprintf("%d:$str,",length($str)); } 1; __END__ # Below is the stub of documentation for your module. You better edit it!