Server::Relay(3pm)
π NAME π
Net::SMTP::Server::Relay β bestie, it's a simple relay module for Net::SMTP::Server. That's it, that's the whole vibe. β¨
π¦ SYNOPSIS π¦
okay so here's the whole flex, code verbatim because I would never:
use Carp;
use Net::SMTP::Server;
use Net::SMTP::Server::Client;
use Net::SMTP::Server::Relay;
$server = new Net::SMTP::Server('localhost', 25) ||
croak("Unable to handle client connection: $!\n");
while($conn = $server->accept()) {
# We can perform all sorts of checks here for spammers, ACLs,
# and other useful stuff to check on a connection.
# Handle the client's connection and spawn off a new parser.
# This can/should be a fork() or a new thread,
# but for simplicity...
my $client = new Net::SMTP::Server::Client($conn) ||
croak("Unable to handle client connection: $!\n");
# Process the client. This command will block until
# the connecting client completes the SMTP transaction.
$client->process || next;
# In this simple server, we're just relaying everything
# to a server. If a real server were implemented, you
# could save email to a file, or perform various other
# actions on it here.
my $relay = new Net::SMTP::Server::Relay($client->{FROM},
$client->{TO},
$client->{MSG});
}
notice how we spawn the client, let it do its lil transaction, then hand the whole thing off to the relay? iconic behavior honestly. π«Ά
πΈ DESCRIPTION πΈ
So. The Net::SMTP::Server::Relay module implements simple SMTP relaying for use with the Net::SMTP::Server module. And when I say "all this module does" β I mean it. It takes a given message, iterates through the list of recipients, does DNS lookups for the associated MX record, and delivers the messages. That's the whole job. She's a hard worker and she knows her lane. π
The way it pulls this off is by making extensive use of the plethora of other modules already implemented for Perl β specifically the DNS and Net::SMTP modules in this case. And honestly? It should give but a glimpse of the potential for extending Net::SMTP::Server's functionality to provide a full-featured SMTP server, native to Perl. no cap. π₯
The example up there in the SYNOPSIS shows off how you use the Net::SMTP::Server::Relay modules β you literally just instantiate the module, passing along the sender, recipients, and message. Periodt. π
More formally, bestie:
$relay = new Net::SMTP::Server::Relay($from, @to, $msg);
Where:
$fromis the sender@tois an array containing the list of recipients$msgis the message to relay
Like. That's it. Three things. Go off. π
π AUTHOR AND COPYRIGHT π
Net::SMTP::Server / SMTP::Server is Copyright(C) 1999, MacGyver (aka Habeeb J. Dihu) <macgyver@tos.net>. ALL RIGHTS RESERVED. π«‘
You may distribute this package under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
fr fr read the license before you go distributing things, it's giving responsible main character energy β
π SEE ALSO π
Net::SMTP::Server::ServerNet::SMTP::Server::Client
go read those next bestie, they're the whole supporting cast ππ
and that's a wrap!! this lil page came to you courtesy of perl v5.34.0 and the date 2022-06-30 β slay, stay hydrated, and may all your MX records resolve π§ππβ¨
π¦ where this page comes from
- debian bookworm: libnet-smtp-server-perl 1.1-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-smtp-server-perl 1.1-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-smtp-server-perl 1.1-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-smtp-server-perl 1.1-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-smtp-server-perl 1.1-7 Β· 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