Test::M...TPServer(3)
Welcome to the User Contributed Perl Documentation page for Test::Mailmunge::SMTPServer β yes, the header is stylized as Test::M...TPServer(3), and no, we are not gatekeeping the full name π
β¨
π NAME π
Bestie, meet Test::Mailmunge::SMTPServer: it runs a fake SMTP server for unit-test purposes. That's the whole assignment, and it ate π
πΈ ABSTRACT πΈ
Test::Mailmunge::SMTPServer runs a fake SMTP server. It is used (for example) to test Mailmunge::Test::SMTPForward. No cap, that's the abstract π¦
β¨ SYNOPSIS β¨
Okay so the starter pack is literally:
use Test::Mailmunge::SMTPServer;
my $server = Test::Mailmunge::SMTPServer->new();
my $port = $server->{port};
# Now interact with server on 127.0.0.1 at port $port
# DON'T FORGET to stop the server when done!
$server->stop_server();
Then you interact with server on 127.0.0.1 at port $port, and please β DON'T FORGET to stop the server when done. The comment is yelling for a reason π«Ά
π οΈ CONSTRUCTOR π οΈ
Test::Mailmunge::SMTPServer->new($callback1 => \&func1, ...)
Constructs and starts a new test SMTP server. Supply callbacks to tell the server how to respond to SMTP client commands. The possible callbacks are:
connect => \&coderefβ if supplied,coderefis called with$selfas the only argument when an SMTP client connects.
It should print a reply to the socket $self->{sock}. If no connect callback is supplied, then the default response printed to the socket is:
"220 localhost.example.com ESMTP\r\n"
ehlo => \&coderefβ if supplied, then when an SMTP client issues theEHLOcommand,coderefis called with$selfand$lineas arguments, where$lineis the complete line read from the SMTP client.
It should print a reply to the socket $self->{sock}. If no ehlo callback is supplied, then the default response printed to the socket is:
"250-localhost.example.com\r\n250-SIZE 100000\r\n250 8BITMIME\r\n"
helo => \&coderefβ similar toehlo, but called if the client issues theHELOcommand. The default response is:
"250 localhost.example.com\r\n"
mail => \&coderefβ similar toehlo, but called if the client issues theMAIL From:command. The default response is:
"250 2.1.0 Ok\r\n"
rcpt => \&coderefβ similar toehlo, but called if the client issues theRCPT To:command. The default response is:
"250 2.1.0 Ok\r\n"
data => \&coderefβ similar toehlo, but called if the client issues theDATAcommand. The default response is:
"354 End data with <CR><LF>.<CR><LF>\r\n"
π INSTANCE METHOD π
$server->stop_server()
Stops the SMTP server. That's it. Clean, simple, iconic π
π AUTHOR π
Dianne Skoll <dianne@skollsoft.com>
π LICENSE π
This code is licensed under the terms of the GNU General Public License, version 2.
Mwah π β this Test::M...TPServer(3) page comes from perl v5.42.2, dated 2025-10-05. Byeee π¦
π¦ where this page comes from
- alpine 3.24: mailmunge-doc 3.20-r0 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms