qpsmtpd/plugins/queue/postfix-queue

45 lines
1.0 KiB
Plaintext
Raw Normal View History

=head1 NAME
postfix-queue
=head1 DESCRIPTION
This plugin passes mails on to the postfix cleanup daemon.
=head1 CONFIG
It takes one optional parameter, the location of the cleanup socket.
If set the environment variable POSTFIXQUEUE overrides this setting.
=cut
use Qpsmtpd::Postfix;
sub register {
my ($self, $qp, @args) = @_;
if (@args > 0) {
$self->{_queue_socket} = $args[0];
$self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if (@args > 1);
} else {
$self->{_queue_socket} = "/var/spool/postfix/public/cleanup";
}
$self->{_queue_socket} = $ENV{POSTFIXQUEUE} if $ENV{POSTFIXQUEUE};
}
sub hook_queue {
my ($self, $transaction) = @_;
my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction);
$status and return(DECLINED, "Unable to queue message ($status, $reason)");
my $msg_id = $transaction->header->get('Message-Id') || '';
$msg_id =~ s/[\r\n].*//s; # don't allow newlines in the Message-Id here
return (OK, "Queued! $msg_id (Queue-Id: $qid)");
}
#vim: sw=2 ts=8