-my $ret = $filter->delivery($mime);
-if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message
- $mime = $ret;
-} elsif ($ret == PublicInbox::Filter::Base::IGNORE) {
- do_exit(0); # chuck it to emergency
-} elsif ($ret == PublicInbox::Filter::Base::REJECT) {
- $! = $ret;
- die $filter->err, "\n";
-} # else { accept
+my @rejects;
+for my $ibx (@$dests) {
+ mda_filter_adjust($ibx);
+ my $filter = $ibx->filter;
+ my $mime = PublicInbox::MIME->new($str);
+ my $ret = $filter->delivery($mime);
+ if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message
+ $mime = $ret;
+ } elsif ($ret == PublicInbox::Filter::Base::IGNORE) {
+ next; # nothing, keep looping
+ } elsif ($ret == PublicInbox::Filter::Base::REJECT) {
+ push @rejects, $filter->err;
+ next;
+ }
+
+ PublicInbox::MDA->set_list_headers($mime, $ibx);
+ my $im = $ibx->importer(0);
+ if (defined $im->add($mime)) {
+ # ->abort is idempotent, no emergency if a single
+ # destination succeeds
+ $emm->abort;
+ } else { # v1-only
+ my $mid = $mime->header_obj->header_raw('Message-ID');
+ # this message is similar to what ssoma-mda shows:
+ print STDERR "CONFLICT: Message-ID: $mid exists\n";
+ }
+ $im->done;
+}