Test::Mock::Net::Server::Mail - mock SMTP server for use in tests
version 1.00
In a test:
use Test::More; use Test::Mock::Net::Server::Mail; use_ok(Net::YourClient); my $s = Test::Mock::Net::Server::Mail->new; $s->start_ok; my $c = Net::YourClient->new( host => $s->bind_address, port => $s->port, ); # check... $s->stop_ok;
Test::Mock::Net::Server::Mail is a mock SMTP server based on Net::Server::Mail. If could be used in unit tests to check SMTP clients.
It will accept all MAIL FROM and RCPT TO commands except they start with 'bad' in the user or domain part. And it will accept all mail except mail containing the string 'bad mail content'.
If a different behaviour is need a subclass could be used to overwrite process_<cmd> methods.
The address to bind to.
First port number to try when searching for a free port.
Load 8BITMIME extension?
Load PIPELINING extension?
Load STARTTLS extension?
Retrieve the port of the running mock server.
Retrieve the process id of the running mock server.
Overwrite this method in a subclass if you need to register additional command callbacks via Net::Server::Mail.
Net::Server::Mail object is passed via $smtp.
Overwrite on of this methods in a subclass if you need to implement your own handler.
Start main loop.
Will accept connections forever and will never return.
Start mock server in background (fork).
After the server is started $obj->port and $obj->pid will be set.
Start the mock server and return a test result.
Stop mock smtp server.
Stop the mock server and return a test result.
Markus Benning <ich@markusbenning.de>
This software is copyright (c) 2015 by Markus Benning <ich@markusbenning.de>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::Mock::Net::Server::Mail, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Mock::Net::Server::Mail
CPAN shell
perl -MCPAN -e shell install Test::Mock::Net::Server::Mail
For more information on module installation, please visit the detailed CPAN module installation guide.