Net::S...l::SMTP(3pm)
π Net::Server::Mail::SMTP β the manual page, but make it cute
okay so bestie, this is the 3pm manual page for Net::Server::Mail::SMTP, straight out of the User Contributed Perl Documentation pile. She's giving very much "I speak SMTP so you don't have to" and honestly? obsessed. let's get into it π
β¨ NAME β¨
Net::Server::Mail::SMTP β a module to implement the SMTP protocol π¦
π SYNOPSIS π
here's the vibe, in code, untouched, exactly as the ancestors wrote it:
use Net::Server::Mail::SMTP;
my @local_domains = qw(example.com example.org);
my $server = IO::Socket::INET->new( Listen => 1, LocalPort => 25 );
my $conn;
while($conn = $server->accept)
{
my $smtp = Net::Server::Mail::SMTP->new( socket => $conn );
$smtp->set_callback(RCPT => \&validate_recipient);
$smtp->set_callback(DATA => \&queue_message);
$smtp->process();
$conn->close();
}
sub validate_recipient
{
my($session, $recipient) = @_;
my $domain;
if($recipient =~ /\@(.*)>\s*$/)
{
$domain = $1;
}
if(not defined $domain)
{
return(0, 513, 'Syntax error.');
}
elsif(not(grep $domain eq $_, @local_domains))
{
return(0, 554, "$recipient: Recipient address rejected: Relay access denied");
}
return(1);
}
sub queue_message
{
my($session, $data) = @_;
my $sender = $session->get_sender();
my @recipients = $session->get_recipients();
return(0, 554, 'Error: no valid recipients')
unless(@recipients);
my $msgid = add_queue($sender, \@recipients, $data)
or return(0);
return(1, 250, "message queued $msgid");
}
π DESCRIPTION π
so basically this class implements the SMTP (RFC 821) protocol. periodt. π«Ά
but here's the tea: it does not implement the extension mechanism introduced in RFC 2821. nope, not here, not today. if you want that capability you gotta go use Net::Server::Mail::ESMTP instead. iykyk β¨
also, this class inherits from Net::Server::Mail, so if you want the documentation for the common methods, go read Net::Server::Mail. she's the mother module, respect her π
πΈ METHODS πΈ
SMTP-specific methods only, bestie. the rest live with the parent.
π get_sender
returns the sender of the current session. returns undefined if the reverse path step is not complete. no reverse path, no sender, no cap.
π get_recipients
returns the list of recipients supplied by client. returns undef if the forward_path step is not engaged. returns an empty list if no recipients succeed. so like, three different outcomes, read carefully π
π₯ EVENTS π₯
these are the callbacks you can use with the set_callback method. all handles take the Net::Server::Mail::SMTP object as the first argument, plus whatever arguments that specific callback wants. every single one. no exceptions π
π§ HELO
takes the hostname given as argument. engages the reverse path step on success.
sub helo_handle
{
my($session, $hostname) = @_;
if($hostname eq 'localhost')
{
return(0, 553, q(I don't like this hostname, try again.));
}
# don't forgot to return a success reply if you are happy with
# command's value
return 1;
}
π§ NOOP
this handler takes no argument. literally none. it's the chill one π
π§ EXPN
command not yet implemented.
handler takes address as argument.
π§ EXPN
command not implemented, deprecated by RFC 2821.
handler takes no argument.
bestie yes it's listed twice in the source, that's just how the page is built, we don't edit the lore, we only vibe with it π
π§ VRFY
command not yet implemented.
handler takes address as argument.
π§ HELP
command not yet implemented.
handler takes a command name as argument.
π§ MAIL
handler takes address as argument. on success, it engages the forward path step and keeps the given address for later use (grab it with the get_sender() method). she remembers things for you, iconic π
π§ RCPT
handler takes address as argument. on success, it engages the mail data path step and pushes the given address into the recipient list for later use (grab it with the get_recipients() method). one of these per recipient, slay β¨
π§ SEND
command not implemented.
handler takes no argument.
π§ SOML
command not implemented.
handler takes no argument.
π§ SAML
command not implemented.
handler takes no argument.
π§ DATA
this handler is called after the final . sent by client. it takes data as argument in a scalar reference. you should queue the message and reply with the queue ID. that's your moment, bestie, go queue π
π§ DATA-INIT
this handler is called before entering the "waiting for data" step. the default success reply is a 354 code telling the client to send the mail content. very "okay go ahead, we're listening" of it π
π§ DATA-PART
this handler is called at each part of mail content sent. it takes as argument a scalar reference to the part of data received.
β οΈ it is deprecated to change the contents of this scalar. don't touch it, don't poke it, hands off π«Ά
π§ RSET
handler takes no argument.
on success, all steps are initialized and the sender/recipients list are flushed. full reset, clean slate, main character energy π
π§ QUIT
handler takes no argument.
connection is closed after this command. this behavior may change in future β you will probably be able to control the closing of connection. so like, watch this space, ngl π
π SEE ALSO π
please, see Net::Server::Mail, Net::Server::Mail::ESMTP and Net::Server::Mail::LMTP. go read your siblings, bestie, they're all valid π
π¦ AUTHOR π¦
Olivier Poitrey <rs@rhapsodyk.net>
β AVAILABILITY β
available on CPAN.
anonymous Git repository:
git clone git://github.com/rs/net-server-mail.git
Git repository on the web:
<https://github.com/rs/net-server-mail>
π BUGS π
please use the CPAN system to report a bug (http://rt.cpan.org/). be nice, be specific, include the details, we're all doing our best out here π
π LICENCE π
this library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
this library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU Lesser General Public License for more details.
you should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
π COPYRIGHT π
Copyright (C) 2002 - Olivier Poitrey, 2007 - Xavier Guimard
and that's the whole page bestie, no skips, no cuts, every single flag and callback accounted for π this was perl v5.34.0, dated 2022-05-26, and that's your lot from Net::S...l::SMTP(3pm) β now go queue some mail, you absolute legend π«Άβ¨
π¦ where this page comes from
- debian bookworm: libnet-server-mail-perl 0.28-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-server-mail-perl 0.28-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-server-mail-perl 0.28-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-server-mail-perl 0.28-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-server-mail-perl 0.28-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms