feat: use new version of Net::LMTP

This commit is contained in:
Dominik Meyer 2025-02-07 15:46:07 +01:00
parent cef7411ec1
commit 198829ad45
Signed by: byterazor
GPG Key ID: EABDA0FD5981BC97

View File

@ -1,8 +1,8 @@
use strict; use strict;
use warnings; use warnings;
use Qpsmtpd::Constants; use Qplmtpd::Constants;
use Qpsmtpd::DSN; use Qplmtpd::DSN;
use Net::LMTP; use Net::LMTP;
@ -28,21 +28,34 @@ sub lmtp_transfer
{ {
my ($self, $transaction, $lmtp_host, $lmtp_port, $lmtp_user) = @_; my ($self, $transaction, $lmtp_host, $lmtp_port, $lmtp_user) = @_;
my $lmtp = Net::LMTP->new($lmtp_host, $lmtp_port); my $lmtp = Net::LMTP->new(
$lmtp->hellp($self->{qp}->config("me")); $lmtp_host,
$lmtp->mail($transaction->sender->address); Port => $lmtp_port,
$lmtp->recipient($lmtp_user); Timeout => 60,
$lmtp->data(); Hello => $self->qp->config("me"),
$lmtp->datasend($transaction->header->as_string); ) || die $!;
$lmtp->mail($transaction->sender->address || "")
or return DECLINED, "Unable to queue message ($!)";
$lmtp->to($lmtp_user) or return DECLINED, "Unable to queue message ($!)";
$lmtp->data() or return DECLINED, "Unable to queue message ($!)";
$lmtp->datasend($transaction->header->as_string)
or return DECLINED, "Unable to queue message ($!)";
$transaction->body_resetpos; $transaction->body_resetpos;
while (my $line = $transaction->body_getline) { while (my $line = $transaction->body_getline) {
$lmtp->datasend($line) $lmtp->datasend($line)
or return DECLINED, "Unable to queue message ($!)"; or return DECLINED, "Unable to queue message ($!)";
} }
$lmtp->dataend(); $lmtp->dataend() or return DECLINED, "Unable to queue message ($!)";
$lmtp->quit(); my $qid = $lmtp->message();
my @list = split(' ', $qid);
$qid = pop(@list);
$lmtp->quit() or return DECLINED, "Unable to queue message ($!)";
$self->log(LOGINFO, "finished queueing"); $self->log(LOGINFO, "finished queueing");
return OK; return OK, "queued as $qid";
return DECLINED; return DECLINED;
} }