Added a simple smtpd for testing
MERGE: Added ability for WebGUI::Test->getPage to work on Operations MERGE: Fix for AdSpace and tests for Operation::AdSpace Fixed Poll's use of JSON Added tests for emailOverride
This commit is contained in:
parent
b27d14f2e5
commit
53ac4be8d1
7 changed files with 315 additions and 99 deletions
48
t/smtpd.pl
Normal file
48
t/smtpd.pl
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
my $HOST = shift;
|
||||
my $PORT = shift;
|
||||
|
||||
die "HOST must be first argument"
|
||||
unless $HOST;
|
||||
die "PORT must be second argument"
|
||||
unless $PORT;
|
||||
|
||||
use JSON qw( to_json );
|
||||
use Net::SMTP::Server;
|
||||
use Net::SMTP::Server::Client;
|
||||
|
||||
my $server = Net::SMTP::Server->new( $HOST, $PORT );
|
||||
|
||||
while ( my $conn = $server->accept ) {
|
||||
my $client = Net::SMTP::Server::Client->new( $conn );
|
||||
$client->process;
|
||||
print to_json({
|
||||
to => $client->{TO},
|
||||
from => $client->{FROM},
|
||||
contents => $client->{MSG},
|
||||
});
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
t/smtpd.pl - A dumb SMTP server.
|
||||
|
||||
=head1 USAGE
|
||||
|
||||
perl smtpd.pl <hostname> <port>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This program listens on the given hostname and port, then processes the
|
||||
incoming SMTP client request.
|
||||
|
||||
Then it prints a JSON object of the data recieved and exits.
|
||||
|
||||
This program will only handle one request before exiting.
|
||||
|
||||
=head1 CAVEATS
|
||||
|
||||
You MUST C<sleep 1> after opening a pipe to this so that it can establish the
|
||||
listening on the port.
|
||||
Loading…
Add table
Add a link
Reference in a new issue