improve handling of SMTP test server
This commit is contained in:
parent
1c7d8c5050
commit
7d0f1e4b8a
2 changed files with 51 additions and 45 deletions
26
t/smtpd.pl
26
t/smtpd.pl
|
|
@ -1,20 +1,18 @@
|
|||
|
||||
my $HOST = shift;
|
||||
my $PORT = shift;
|
||||
my $EMAILS = shift || 1;
|
||||
|
||||
die "HOST must be first argument"
|
||||
unless $HOST;
|
||||
die "PORT must be second argument"
|
||||
unless $PORT;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use JSON qw( to_json );
|
||||
use Net::SMTP::Server;
|
||||
use Net::SMTP::Server::Client;
|
||||
|
||||
my $server = Net::SMTP::Server->new( $HOST, $PORT );
|
||||
my ($HOST, $PORT) = @ARGV;
|
||||
|
||||
my $counter = 0;
|
||||
die "HOST must be first argument"
|
||||
unless $HOST;
|
||||
die "PORT must be second argument"
|
||||
unless $PORT;
|
||||
|
||||
my $server = Net::SMTP::Server->new( $HOST, $PORT );
|
||||
|
||||
$| = 1;
|
||||
|
||||
|
|
@ -25,16 +23,10 @@ CONNECTION: while ( my $conn = $server->accept ) {
|
|||
to => $client->{TO},
|
||||
from => $client->{FROM},
|
||||
contents => $client->{MSG},
|
||||
counter => $counter,
|
||||
emails => $EMAILS,
|
||||
});
|
||||
print "\n";
|
||||
last CONNECTION if ++$counter >= $EMAILS;
|
||||
}
|
||||
|
||||
sleep 3;
|
||||
exit(0);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
t/smtpd.pl - A dumb SMTP server.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue