-
-
Notifications
You must be signed in to change notification settings - Fork 23
How do I save DMARC reports?
msimerson edited this page Nov 2, 2014
·
2 revisions
By default, validating messages against Mail::DMARC does not save the validation information in the database.
For sites who choose to be DMARC reporters (in addition to validators), the application that call Mail::DMARC must also tell Mail::DMARC to store the report. In addition, something must call dmarc_send_reports
once a day to send out the reports. Telling Mail::DMARC to save the reports can be done like this:
if ( $dmarc->has_valid_reporting_uri($pol->rua) ) {
eval { $dmarc->save_aggregate(); };
}
If the caller to Mail::DMARC cannot be easily altered, patching Mail::DMARC::PurePerl like this would also do:
diff --git a/lib/Mail/DMARC/PurePerl.pm b/lib/Mail/DMARC/PurePerl.pm
index 6ccb4d3..115a582 100644
--- a/lib/Mail/DMARC/PurePerl.pm
+++ b/lib/Mail/DMARC/PurePerl.pm
@@ -38,8 +38,15 @@ sub validate {
$self->is_dkim_aligned; # 11.2.3. DKIM signature verification checks
$self->is_spf_aligned; # 11.2.4. SPF validation checks
- $self->is_aligned() # 11.2.5. identifier alignment checks
- and return $self->result;
+ my $aligned = $self->is_aligned(); # 11.2.5. identifier alignment checks
+
+ my $pol;
+ eval { $pol = $self->result->published; };
+ if ( $pol && $self->has_valid_reporting_uri($pol->rua) ) {
+ eval { $self->save_aggregate(); };
+ };
+
+ return $self->result if $aligned;
my $effective_p
= $self->is_subdomain && defined $policy->sp