this patch enables the configurable flags for the postfix-queue plugin.
By default no flags are set (old behaviour). Known flags for cleanup are FLAG_FILTER, FLAG_BCC_OK and FLAG_MAP_OK, see POD for details. Patch by: Hanno Hecker <hah@uu-x.de> git-svn-id: https://svn.perl.org/qpsmtpd/branches/0.3x@600 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
c0920346e5
commit
d228f9c11d
@ -162,7 +162,7 @@ sub inject_mail {
|
|||||||
my %at = $strm->get_attr;
|
my %at = $strm->get_attr;
|
||||||
my $qid = $at{queue_id};
|
my $qid = $at{queue_id};
|
||||||
print STDERR "qid=$qid\n";
|
print STDERR "qid=$qid\n";
|
||||||
$strm->print_attr('flags' => '0000');
|
$strm->print_attr('flags' => $transaction->notes('postfix-queue-flags'));
|
||||||
$strm->print_rec_time();
|
$strm->print_rec_time();
|
||||||
$strm->print_rec('REC_TYPE_FROM', $transaction->sender->address|| "");
|
$strm->print_rec('REC_TYPE_FROM', $transaction->sender->address|| "");
|
||||||
for (map { $_->address } $transaction->recipients) {
|
for (map { $_->address } $transaction->recipients) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
postfix-queue
|
postfix-queue
|
||||||
@ -8,21 +9,70 @@ This plugin passes mails on to the postfix cleanup daemon.
|
|||||||
|
|
||||||
=head1 CONFIG
|
=head1 CONFIG
|
||||||
|
|
||||||
It takes one optional parameter, the location of the cleanup socket.
|
The first optional parameter is the location of the cleanup socket. If it does
|
||||||
|
not start with a ``/'', it is treated as a flag for cleanup (see below).
|
||||||
|
If set, the environment variable POSTFIXQUEUE overrides this setting.
|
||||||
|
|
||||||
If set the environment variable POSTFIXQUEUE overrides this setting.
|
All other parameters are flags for cleanup, no flags are enabled by default.
|
||||||
|
Known flags are:
|
||||||
|
|
||||||
|
=over 3
|
||||||
|
|
||||||
|
=item FLAG_FILTER
|
||||||
|
|
||||||
|
Set the CLEANUP_FLAG_FILTER for cleanup. This enables the use of
|
||||||
|
I<header_filter>, I<body_filter> or I<content_filter> in postfix' main.cf.
|
||||||
|
|
||||||
|
=item FLAG_BCC_OK
|
||||||
|
|
||||||
|
Setting this flag enables (for example) the I<recipient_bcc_maps> parameter
|
||||||
|
|
||||||
|
=item FLAG_MAP_OK
|
||||||
|
|
||||||
|
This flag enables the use of other recipient mappings (e.g.
|
||||||
|
I<virtual_alias_maps>) in postfix' cleanup.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use Qpsmtpd::Postfix;
|
use Qpsmtpd::Postfix;
|
||||||
|
|
||||||
|
#
|
||||||
|
# postfix' cleanup flags:
|
||||||
|
use constant CLEANUP_FLAG_FILTER => (1 << 1); # /* Enable content filter */
|
||||||
|
use constant CLEANUP_FLAG_BCC_OK => (1 << 4); # /* Ok to add auto-BCC addresses */
|
||||||
|
use constant CLEANUP_FLAG_MAP_OK => (1 << 5); # /* Ok to map addresses */
|
||||||
|
|
||||||
sub register {
|
sub register {
|
||||||
my ($self, $qp, @args) = @_;
|
my ($self, $qp, @args) = @_;
|
||||||
|
|
||||||
|
$self->{_queue_flags} = 0;
|
||||||
if (@args > 0) {
|
if (@args > 0) {
|
||||||
$self->{_queue_socket} = $args[0];
|
if ($args[0] =~ m#^/#) {
|
||||||
$self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if (@args > 1);
|
$self->{_queue_socket} = shift @args;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
$self->{_queue_socket} = "/var/spool/postfix/public/cleanup";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (@args) {
|
||||||
|
if ($_ eq 'FLAG_FILTER') {
|
||||||
|
$self->{_queue_flags} |= CLEANUP_FLAG_FILTER;
|
||||||
|
}
|
||||||
|
elsif ($_ eq 'FLAG_BCC_OK') {
|
||||||
|
$self->{_queue_flags} |= CLEANUP_FLAG_BCC_OK;
|
||||||
|
}
|
||||||
|
elsif ($_ eq 'FLAG_MAP_OK') {
|
||||||
|
$self->{_queue_flags} |= CLEANUP_FLAG_MAP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
$self->log(LOGWARN, "Ignoring unkown cleanup flag $_");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$self->{_queue_socket} = "/var/spool/postfix/public/cleanup";
|
$self->{_queue_socket} = "/var/spool/postfix/public/cleanup";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +82,9 @@ sub register {
|
|||||||
|
|
||||||
sub hook_queue {
|
sub hook_queue {
|
||||||
my ($self, $transaction) = @_;
|
my ($self, $transaction) = @_;
|
||||||
|
$transaction->notes('postfix-queue-flags', $self->{_queue_flags});
|
||||||
|
|
||||||
|
# $self->log(LOGDEBUG, "queue-flags=".$transaction->notes('postfix-queue-flags'));
|
||||||
my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction);
|
my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction);
|
||||||
$status and return (DECLINED, "Unable to queue message ($status, $reason)");
|
$status and return (DECLINED, "Unable to queue message ($status, $reason)");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user