| Net-SMTP-Server-Client2 documentation | view source | Contained in the Net-SMTP-Server-Client2 distribution. |
Net::SMTP::Server::Client2 - A better client for Net::SMTP::Server.
use Carp;
use Net::SMTP::Server;
use Net::SMTP::Server::Client2;
my $server = new Net::SMTP::Server(localhost => 25) ||
croak("Unable to open server : $!\n");
while($conn = $server->accept()) {
fork and last;
$conn->close;
};
my $count = 'aaa';
my $client = new Net::SMTP::Server::Client2($conn) ||
croak("Unable to handle client: $!\n");
$client->greet; # this is new
while($client->get_message){ # this is different
if (length($client->{MSG}) > 1400000){
$client->too_long; # this is new
}else{
if( $client->{MSG} =~ /viagra/i ){
$client->fail(" we need no viagra "); # this is new
next;
};
$count++;
open MOUT, ">/tmp/tmpMOUT_${$}_$count" or die "open: $!";
print MOUT join("\n",
$client->{FROM},
@{$client->{TO}},
'',
$client-{MSG}) or die "print: $!";
close MOUT or die "close: $!";
link
"/tmp/tmpMOUT_${$}_$count",
"/tmp/MOUT_${$}_$count"
or die "link: $!";
unlink
"/tmp/tmpMOUT_${$}_$count"
or die "unlink: $!";
$client->okay("message saved for relay"); # this is new
}}
The Net::SMTP::Server::Client2 module is a patched Net::SMTP::Server::Client module.
$client->get_message returns before delivering a response
code to the client. $client->okay(...) and $client->too_large()
and $client->fail(...) return the appropriate codes, rather than
assuming that all messages were 250. "Is that 250 with you?"
$client->basta() will 421 and close, which is also an option after
receiving a message you don't want to accept.
$client->{faults} is the number of booboos the client made while
presenting the message, after 15 of them we 421 and close.
And, Client2 is no longer is an autoloader or an exporter because it doesn't export anything or autoload.
Net::SMTP::Server::Client is Copyright(C) 1999, MacGyver (aka Habeeb J. Dihu), who released it under the AL and GPL, so it is okay to patch and re-release it, even though he said "all reigths reserved." He reserved all the rights, then he released it. Go figure. Client2, released by me, in 2002, contains changes that make the interface more complex, and not backwards-compatible. You may distribute this package under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. David Nicol
Net::SMTP::Server, Net::SMTP::Server::Client
| Net-SMTP-Server-Client2 documentation | view source | Contained in the Net-SMTP-Server-Client2 distribution. |