Net::S...l::LMTP(3pm)

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

✨ NAME ✨

ok so bestie, welcome to Net::Server::Mail::LMTP πŸ’– β€” it's the perl module (3pm, yes we're fancy) that implements the LMTP protocol. That's it, that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

ok here's the whole thing, no gatekeeping:

use Net::Server::Mail::LMTP;

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 $esmtp = Net::Server::Mail::LMTP->new( socket => $conn );
    # adding some handlers
    $esmtp->set_callback(RCPT => \&validate_recipient);
    $esmtp->set_callback(DATA => \&queue_message);
    $esmtp->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 πŸ’…

This class implements the LMTP protocol, aka RFC 2033. iconic behavior fr fr πŸ’–

This class inherits from Net::Server::Mail::ESMTP. so if you wanna know about the common methods, go read Net::Server::Mail::ESMTP β€” that's where the shared lore lives πŸ¦‹


πŸŽ€ EVENTS πŸŽ€

ok so this is the descriptions of the callbacks you can use with the set_callback method. and listen β€” every single handler takes the Net::Server::Mail::ESMTP object as its first argument, plus whatever args that specific callback needs. that's the rule, periodt ✨

🌈 LHLO

Same as ESMTP's EHLO bestie. go see Net::Server::Mail::ESMTP for the details πŸ‘‘

🌸 DATA

This one overrides the default DATA event and gives you a per recipient response. It gets called for each recipient, with the data (as a scalar reference, mind you πŸ’…) as the first argument, followed by the current recipient.


πŸ¦‹ SEE ALSO πŸ¦‹

Please, go check out Net::Server::Mail, Net::Server::Mail::SMTP and Net::Server::Mail::ESMTP. the whole friend group, basically 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Olivier Poitrey <rs@rhapsodyk.net> πŸ’œ


⭐ AVAILABILITY ⭐

Available on CPAN. yes queen, it's out there πŸŽ€

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/). we love a paper trail, no cap 😭


πŸ’– 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

fr fr, that ALL CAPS part is not a vibe, it's a legally binding vibe. read it. πŸ’€

Copyright (C) 2002 - Olivier Poitrey, 2007 - Xavier Guimard


ok that's the whole page bestie, you ate it πŸ’…βœ¨ this was Net::Server::Mail::LMTP(3pm) from the perl manual, version perl v5.34.0, dated 2022-05-26 β€” love that for us, now go write some LMTP πŸ«ΆπŸ’–

πŸ“¦ where this page comes from