Server::Client(3pm)

πŸ“¦
version 1.1 Β· 2 versions
  • 1.1 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.1 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Server::Client(3pm) πŸ’–

okay bestie, pull up a chair, we're talking about Net::SMTP::Server::Client β€” that's the client session handling piece of the Net::SMTP::Server world, from the Perl user-contributed docs (that's the 3pm vibe, iykyk). it's giving mail server, it's giving lowkey iconic πŸ¦‹


✨ NAME ✨

Net::SMTP::Server::Client β€” client session handling for Net::SMTP::Server. that's the whole assignment, and she ate πŸ’…


✨ SYNOPSIS ✨

here's the whole serve, verbatim, no notes:

  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});
  }

like?? look at her go. πŸŽ€


✨ DESCRIPTION ✨

so the Net::SMTP::Server::Client module does all the session handling you need for a Net::SMTP::Server::Client connection. the example up there πŸ‘† shows you how to pair it with Net::SMTP::Server to handle SMTP connections. they're a duo, they're the main characters fr fr πŸ‘‘

the constructor, bestie

$client = new Net::SMTP::Server::Client($conn)

Net::SMTP::Server::Client takes one argument, and it has to be a handle to a connection β€” that's the thing she'll use to communicate. no handle, no talkie, periodt. πŸ™ˆ

then you do the thing

once you've got yourself a fresh new client session, you literally just call:

$client->process

and that processes an SMTP transaction. πŸŒ€

⚠️ THIS MAY APPEAR TO HANG -- ESPECIALLY IF THERE IS A LARGE AMOUNT OF DATA BEING SENT. bestie she is NOT frozen, she is NOT ghosting you, she is just chewing through a big ol' pile of data. do not panic-refresh. πŸ’€

the moment this method returns, your server will have processed an entire SMTP transaction and is ready to keep it moving. slay. 🌈

the fields that get filled in πŸ’–

once $client->process returns, a bunch of fields are all filled in and ready for you:

  • $client->{TO} β€” this is an array holding the intended recipients for this message. and yes, there can be multiple recipients for any given message, she's popular like that 🫢
  • $client->{FROM} β€” this is the sender of the given message.
  • $client->{MSG} β€” the actual message data. :) ✨

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. pick your fighter, both are valid. πŸ’…


✨ SEE ALSO ✨

go give these their flowers too:

  • Net::SMTP::Server::Server
  • Net::SMTP::Server::Relay

and that's the whole page, bestie!! this doc shipped with perl v5.34.0 and was dated 2022-06-30, and it's filed under the manual page name Server::Client(3pm). go write a mail server, you're gonna do great, ily πŸ¦‹πŸ’–πŸŒΈ

πŸ“¦ where this page comes from