X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-mda;h=9da2d90f8f45f0227cf3083a9a726f322be38947;hb=2710d3105e70ff467eff9e977325628b4e9dd1c5;hp=821bd9cca36bb00d33d074c0c8e37d22f3387be5;hpb=4315455300e29e4ef0ea2f2d68bf4e86d261ae1d;p=public-inbox.git diff --git a/script/public-inbox-mda b/script/public-inbox-mda index 821bd9cc..9da2d90f 100755 --- a/script/public-inbox-mda +++ b/script/public-inbox-mda @@ -9,11 +9,11 @@ my $usage = 'public-inbox-mda [OPTIONS] < rfc2822_message'; my $precheck = grep(/\A--no-precheck\z/, @ARGV) ? 0 : 1; my ($ems, $emm); -sub do_exit { +my $do_exit = sub { my ($code) = shift; $emm = $ems = undef; # trigger DESTROY exit $code; -} +}; use Email::Simple; use PublicInbox::MIME; @@ -44,12 +44,11 @@ if (defined $recipient) { push @$dests, $ibx if $ibx; } if (!scalar(@$dests)) { - my $ibx = PublicInbox::MDA->inbox_for_list_id($config, $simple); - if (!defined($ibx) && !defined($recipient)) { + $dests = PublicInbox::MDA->inboxes_for_list_id($config, $simple); + if (!scalar(@$dests) && !defined($recipient)) { die "ORIGINAL_RECIPIENT not defined in ENV\n"; } - defined($ibx) or do_exit(67); # EX_NOUSER 5.1.1 user unknown - push @$dests, $ibx; + scalar(@$dests) or $do_exit->(67); # EX_NOUSER 5.1.1 user unknown } my $err; @@ -68,7 +67,7 @@ my $err; } } @$dests; -do_exit(67) if $err && scalar(@$dests) == 0; +$do_exit->(67) if $err && scalar(@$dests) == 0; $simple = undef; my $spam_ok; @@ -85,7 +84,7 @@ if ($spamc) { my $fh = $emm->fh; read($fh, $str, -s $fh); } -do_exit(0) unless $spam_ok; +$do_exit->(0) unless $spam_ok; # -mda defaults to the strict base filter which we won't use anywhere else sub mda_filter_adjust ($) { @@ -132,4 +131,4 @@ if (scalar(@rejects) && scalar(@rejects) == scalar(@$dests)) { die join("\n", @rejects, ''); } -do_exit(0); +$do_exit->(0);