Net::SMTP::Server::Client2 - A better client for Net::SMTP::Server.


Net-SMTP-Server-Client2 documentation  | view source Contained in the Net-SMTP-Server-Client2 distribution.

Index


NAME

Top

Net::SMTP::Server::Client2 - A better client for Net::SMTP::Server.

SYNOPSIS

Top

        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
         }}







DESCRIPTION

Top

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.

AUTHOR AND COPYRIGHT

Top

SEE ALSO

Top

Net::SMTP::Server, Net::SMTP::Server::Client


Net-SMTP-Server-Client2 documentation  | view source Contained in the Net-SMTP-Server-Client2 distribution.