X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=script%2Fpublic-inbox-mda;h=2655a6c5ed064aad67b97f0c575a3212cde68344;hp=183b915da86275e416ef5dc7a9935100d2c005a4;hb=7e881ac8227d1882c92de6f6701ffcba7cef9191;hpb=466df3e029fecdabac373d73989c7fceebe6ae28 diff --git a/script/public-inbox-mda b/script/public-inbox-mda index 183b915d..2655a6c5 100755 --- a/script/public-inbox-mda +++ b/script/public-inbox-mda @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright (C) 2013-2018 all contributors +# Copyright (C) 2013-2019 all contributors # License: AGPL-3.0+ # # Mail delivery agent for public-inbox, run from your MTA upon mail delivery @@ -36,10 +36,21 @@ my $config = PublicInbox::Config->new; my $key = 'publicinboxmda.spamcheck'; my $default = 'PublicInbox::Spamcheck::Spamc'; my $spamc = PublicInbox::Spamcheck::get($config, $key, $default); +my $dst; my $recipient = $ENV{ORIGINAL_RECIPIENT}; -defined $recipient or die "ORIGINAL_RECIPIENT not defined in ENV\n"; -my $dst = $config->lookup($recipient); # first check -defined $dst or do_exit(67); # EX_NOUSER 5.1.1 user unknown +if (defined $recipient) { + $dst = $config->lookup($recipient); # first check +} +if (!defined $dst) { + my $list_id = $simple->header('List-Id'); + if (defined $list_id && $list_id =~ /<[ \t]*(.+)?[ \t]*>/) { + $dst = $config->lookup_list_id($1); + } + if (!defined $dst && !defined $recipient) { + die "ORIGINAL_RECIPIENT not defined in ENV\n"; + } + defined $dst or do_exit(67); # EX_NOUSER 5.1.1 user unknown +} $dst->{mainrepo} or do_exit(67); $dst = PublicInbox::InboxWritable->new($dst); @@ -81,6 +92,7 @@ if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message $! = 65; # EX_DATAERR 5.6.0 data format error die $filter->err, "\n"; } # else { accept +$filter = undef; PublicInbox::MDA->set_list_headers($mime, $dst); my $im = $dst->importer(0);