NetSDS...:SMTPD(3pm)
π NAME π
NetSDS::App::SMTPD β it's giving SMTP server app class, bestie. That's the whole name, that's the whole vibe. β¨
π SYNOPSIS π
use NetSDS::App::SMTPD
That's it. One line. Iconic behavior fr fr. π
π PACKAGES π
Okay so this page is actually a little family reunion β there's a base package and a few friends under it, so let's go one by one, no skipping, we do NOT skip around here. π«Ά
π¦ NetSDS::App::SMTPD::Socket
Needs for work with socket, periodt. This module is a parent for NetSDS::App::SMTPD and NetSDS::App::SMTPD::Client, and a child of a NetSDS::APP. So it's giving both mom and daughter energy, which is honestly so real of it. π
ITEMS
create_socketβ Creating a simple socket which could be transformed into a listening inNetSDS::App::SMTPDand could be used inNetSDS::App::SMTPD::Clientfor accept connection. Lowkey the origin story of every connection. π±can_readβ This method uses for making a timeout before connections to the server: if there is no connections to accept, program would be just waiting inselectwhile the connection appeared. So basically it's the "anyone? anyone? Bueller?" method. πclose_socketβ Close socket. Short. Sweet. Slays. π
πΈ NetSDS::App::SMTPD::Client
Provides the smtp protocol bu using Net::Server::Mail::SMTP. (Yes, "bu" β that's what the original says and we respect the original's choices. π)
Had attributes, bestie, listen up:
smtpβ an object ofNet::Server::Mail::SMTPipβ ip of the remote hostheadersβ ref hash with headers of a messagemsgβ a body of a message
ITEMS
set_callbackandprocessβ All that subs do β its only call the methods of aNet::Server::Mail::SMTPwith the same name. They're not doing extra, they're not doing less. They're middlemen and they're at peace with it. π§get_mailβ In this sub we parse message and set headers of the object and message body. This sub is call as a callback on eventDATA. So whenDATAshows up, this one gets to work. π₯get_headerandget_msgβ Get methods that make you access to a header of a msg and message body. Example:$client->get_header('FROM')or$client->get_header('to');β note that casing is doing whatever it wants in there and we simply pass that along. π
π NetSDS::App::SMTPD
This module init a smtp-server. That's the whole job description and honestly? Respect the brevity.
ITEMS
create_socketβ Init a listening socket by creating a simple socketSuper::create_socketand make it listening. β¨dataβ Takes β a message that has been received, parses them and prepare the structure of headers, body for next actions. It's the prep cook of this whole operation. πacceptβ Waiting for an smtp connection and that accept it. Main character energy: it just stands there until someone shows up. πdataβ (yep,datashows up in this list twice in the original β we do not edit, we do not merge, we simply observe and honor it π)processβ (listed here with no description in the original, so no description it is. We're nothing if not faithful. π«Ά)
π EXAMPLE π
Okay this is the part you actually came for, so here it is, exactly as written:
#!/usr/bin/env perl
use strict;
use warnings;
Receiver->run(
infinite => 1,
debug => 1,
verbose => 1,
conf_file => '../conf/mts-receiver.conf',
);
1;
package Receiver;
use base 'NetSDS::App::SMTPD';
sub process {
my $self = shift;
my $client = $self->SUPER::process;
#do something with msg;
my $from = $client->get_header('from');
my $msg = $client->get_msg;
.....
return $self;
};
or you could reinit process like this:
sub process {
my $self = shift;
my $client = $self->accept;
return unless $client;
$client->process;
#do something
......
$client->close;
return $self;
};
See how the first one rides on SUPER::process and the second one grabs accept directly, checks return unless $client;, runs $client->process;, does something, then $client->close;? Two paths, both valid, both cute. π¦
Heads up bestie: that.....and that......are literally in the original. They are not me being lazy. Do not @ me. π
π AUTHOR π
Yana Kornienko <yana@netstyle.com.ua> β thank you for your service, queen. π
And that's the whole page, no cap. This little gem is from the User Contributed Perl Documentation, it's perl v5.32.1, dated 2021-12-26, and the page itself answers to the name NetSDS...:SMTPD(3pm). Love that for it. Go build something, bestie β you got this. πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- debian trixie: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- ubuntu jammy: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- ubuntu noble: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- ubuntu resolute: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms