my $dst = $config->lookup($recipient);
defined $dst or exit(1);
my $main_repo = $dst->{mainrepo} or exit(1);
-my $fail_repo = $dst->{failrepo} or exit(1);
my $filtered; # string dest
if (PublicInbox->precheck($filter, $recipient) &&
if (PublicInbox::Filter->run($simple)) {
# run spamc again on the HTML-free message
if (do_spamc($simple, \$filtered)) {
- $filter->simple(Email::Simple->new($filtered));
- $filter->pipe(MDA, $main_repo);
- } else {
- $filter->pipe(MDA, $fail_repo);
+ $simple = Email::Simple->new($filtered);
+ set_list_headers($simple, $dst);
+ $filter->simple($simple);
+
+ my $from = $filter->from;
+ my @from = Email::Address->parse($from);
+ my $name = $from[0]->name;
+ defined $name or $name = "";
+ my $email = $from[0]->address;
+ defined $email or $email = "";
+ local $ENV{GIT_AUTHOR_NAME} = $name;
+ local $ENV{GIT_AUTHOR_EMAIL} = $email;
+ local $ENV{GIT_AUTHOR_DATE} = $simple->header("Date");
+ local $ENV{GIT_COMMITTER_EMAIL} = $recipient;
+ local $ENV{GIT_COMMITTER_NAME} = $dst->{listname};
+
+ $filter->pipe(MDA, '-1', $main_repo);
}
- } else {
- # PublicInbox::Filter nuked everything, oops :x
- $filter->pipe(MDA, $fail_repo);
}
-} else {
- # if SA thinks it's spam or there's an error:
- # don't bother with our own filtering
- $filter->pipe(MDA, $fail_repo);
}
-die "Email::Filter failed to exit\n";
+exit 0; # goes to failbox
# we depend on "report_safe 0" in /etc/spamassassin/*.cf with --headers
# not using Email::Filter->pipe here since we want the stdout of
return ($@ || $? || !defined($$out) || length($$out) == 0) ? 0 : 1;
}
+
+# RFC2919 and RFC2369
+sub set_list_headers {
+ my ($simple, $dst) = @_;
+ my $pa = "<$dst->{-primary_address}>";
+ $simple->header_set("List-Id", $pa);
+ $simple->header_set("List-Post", $pa);
+
+ my $url = $dst->{url};
+ if (defined $url) {
+ $simple->header_set("List-Archive", "<$url>");
+ $simple->header_set("List-Help", "<${url}help>");
+ }
+}