Index: opendmarc/reports/opendmarc-reports.in =================================================================== --- opendmarc.orig/reports/opendmarc-reports.in 2018-12-17 01:41:49.094337107 -0500 +++ opendmarc/reports/opendmarc-reports.in 2018-12-17 01:41:49.090337107 -0500 @@ -65,6 +65,7 @@ my $forcedomain; my @skipdomains; +my $poldomain; my $policy; my $spolicy; my $policystr; @@ -441,7 +442,7 @@ next; } - $dbi_s = $dbi_h->prepare("SELECT repuri, adkim, aspf, policy, spolicy, pct, UNIX_TIMESTAMP(lastsent) FROM requests WHERE domain = ?"); + $dbi_s = $dbi_h->prepare("SELECT repuri, adkim, aspf, requests.policy, spolicy, pct, UNIX_TIMESTAMP(lastsent), domains.name FROM requests JOIN messages ON messages.from_domain=requests.domain LEFT JOIN domains ON messages.policy_domain = domains.id WHERE domain = ? GROUP BY policy_domain"); if (!$dbi_s->execute($domainid)) { print STDERR "$progname: can't get reporting URI for domain $domain: " . $dbi_h->errstr . "\n"; @@ -451,6 +452,7 @@ } undef $repuri; + $poldomain=$domain; while ($dbi_a = $dbi_s->fetchrow_arrayref()) { @@ -482,6 +484,10 @@ { $lastsent = $dbi_a->[6]; } + if (defined($dbi_a->[7])) + { + $poldomain = $dbi_a->[7]; + } } $dbi_s->finish; @@ -564,7 +570,7 @@ print $tmpout " \n"; print $tmpout " \n"; - print $tmpout " $domain\n"; + print $tmpout " $poldomain\n"; print $tmpout " $adkimstr\n"; print $tmpout " $aspfstr\n"; print $tmpout "

$policystr

\n";