perl-net-lmtp/lib/Net/LMTP2.pm

52 lines
1.1 KiB
Perl
Raw Normal View History

2025-02-09 20:05:26 +01:00
package Net::LMTP;
# ABSTRACT: A client class for the LMTP protocol
use strict;
use warnings;
use base 'Net::SMTP';
use Net::Cmd;
=head1 DESCRIPTION
This module provides an interface to LMTP servers. It inherits from Net::SMTP. In crontast to Net::LMTP it is actually working.
=head1 USAGE
Just look at Net::SMTP, this is just a derived class and providing
its own hello function as this is the main difference between SMTP and
LMTP.
=cut
sub hello {
my $me = shift;
my $domain = shift || "localhost.localdomain";
my $ok = $me->_LHLO($domain);
my @msg = $me->message;
if ($ok) {
my $h = ${*$me}{'net_smtp_esmtp'} = {};
foreach my $ln (@msg) {
$h->{uc $1} = $2 if $ln =~ /([-\w]+)\b[= \t]*([^\n]*)/;
}
}
elsif ($me->status == CMD_ERROR) {
@msg = $me->message if $ok = $me->_HELO($domain);
}
return unless $ok;
${*$me}{net_smtp_hello_domain} = $domain;
$msg[0] =~ /\A\s*(\S+)/;
return ($1 || " ");
}
sub _EHLO { shift->unsupported(@_);}
sub _HELO { shift->unsupported(@_);}
sub _LHLO { shift->command("LHLO", @_)->response() == CMD_OK }
1;