-PublicInbox::MDA->set_list_headers($mime, $dst);
-my $im = $dst->importer(0);
-if (defined $im->add($mime)) {
- $emm = $emm->abort;
-} else {
- # this message is similar to what ssoma-mda shows:
- print STDERR "CONFLICT: Message-ID: ",
- $mime->header_obj->header_raw('Message-ID'),
- " exists\n";
+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;
+}
+
+if (scalar(@rejects) && scalar(@rejects) == scalar(@$dests)) {
+ $! = 65; # EX_DATAERR 5.6.0 data format error
+ die join("\n", @rejects, '');