QPSMTPD-MailserverInterface/queue/lmtp

65 lines
1.4 KiB
Plaintext

use strict;
use warnings;
use Qpsmtpd::Constants;
use Qpsmtpd::DSN;
sub register {
my ($self, $qp) = (shift, shift);
$self->{lmtp_rcpt_based} = $qp->config("lmtp_rcpt_based") || 0;
$self->{lmtp_host} = $qp->config("lmtp_host");
$self->{lmtp_port} = $qp->config("lmtp_port") || 24;
$self->{enabled} = 1;
if (!$self->{lmtp_rcpt_based} && !$self->{lmtp_host}) {
$self->{enabled} = 0;
$self->log(LOGERROR, "No LMTP host configured, disabling plugin\n");
return;
}
}
sub lmtp_transfer
{
my ($self, $transaction) = @_;
return DECLINED;
}
sub hook_queue {
my ($self, $transaction) = @_;
return DECLINED unless $self->{enabled};
my $lmtp_host;
my $lmtp_port;
my $lmtp_user;
if ($self->{lmtp_rcpt_based})
{
my $queue = $transaction->notes("queue");
$queue =~ /^lmtp:\/\/(.*):(\d+)$/;
$lmtp_host=$1;
$lmtp_port=$2;
my $lmtp_user = $transaction->notes("destination-user") || "";
}
else
{
$lmtp_host = $self->{lmtp_host};
$lmtp_port = $self->{lmtp_port};
$lmtp_user = $transaction->sender->address || "";
}
if (!$lmtp_user) {
$self->log(LOGERR, "No sender address found for transaction.\n");
return DECLINED;
}
$self->log(LOGNOTICE,"forwarding mail to LMTP host: $lmtp_host:$lmtp_port\n");
return $self->lmtp_transfer($transaction);
}