-defined $recipient or die "ORIGINAL_RECIPIENT not defined in ENV\n";
-my $dst = $config->lookup($recipient); # first check
-defined $dst or exit(1);
-my $main_repo = $dst->{mainrepo} or exit(1);
-my $filtered; # string dest
-
-if (PublicInbox::MDA->precheck($filter->simple, $dst->{address}) &&
- do_spamc($filter->simple, \$filtered)) {
- # update our message with SA headers (in case our filter rejects it)
- my $msg = Email::MIME->new(\$filtered);
- $filtered = undef;
- $filter->simple($msg);
-
- my $filter_arg;
- my $fcfg = $dst->{filter};
- if (!defined $fcfg || $filter eq 'reject') {
- $filter_arg = $filter;
- } elsif ($fcfg eq 'scrub') {
- $filter_arg = undef; # the default for legacy versions
- } else {
- warn "publicinbox.$dst->{name}.filter=$fcfg invalid\n";
- warn "must be either 'scrub' or 'reject' (the default)\n";
- }
-
- if (PublicInbox::Filter->run($msg, $filter_arg)) {
- # run spamc again on the HTML-free message
- if (do_spamc($msg, \$filtered)) {
- $msg = Email::MIME->new(\$filtered);
- PublicInbox::MDA->set_list_headers($msg, $dst);
- $filter->simple($msg);
-
- END {
- index_sync($main_repo) if ($? == 0);
- };
- my $git = PublicInbox::Git->new($main_repo);
- my $im = PublicInbox::Import->new($git,
- $dst->{name}, $recipient);
- if (defined $im->add($msg)) {
- $im->done;
- $filter->ignore; # exits
- }
- # this message is similar to what ssoma-mda shows:
- print STDERR "CONFLICT: Message-ID: ",
- $msg->header_obj->header_raw('Message-ID'),
- " exists\n";
- }
+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);