#!/usr/bin/perl
use strict;
use warnings;

use Data::Dumper;

$|++;
use lib 'lib';
use Mail::DMARC::Report;
my $report = Mail::DMARC::Report->new();

# 1. get list of reports where end < now
my $reports_ref = $report->store->retrieve( 'end' => time );
foreach my $report_ref ( @$reports_ref ) {
    print "$report_ref->{domain}\n";
    print "rua: $report_ref->{policy_published}{rua}\n";
    my $xml = $report->assemble_xml( \$report_ref );
    $report->sendit->send_rua(\$report_ref, \$xml) # deliver via SMTP/HTTP
        and $report->store->delete_report($report_ref->{id});
#   print $xml;
    print "sleeping 5";
    foreach ( 1 .. 5 ) { print '.'; sleep 1; };
    print "done.\n";
};

exit;
# PODNAME: dmarc_report
# ABSTRACT: send aggregate reports to requestors

__END__
=pod

=head1 NAME

dmarc_report - send aggregate reports to requestors

=head1 VERSION

version 0.20130520

=head1 AUTHORS

=over 4

=item *

Matt Simerson <msimerson@cpan.org>

=item *

Davide Migliavacca <shari@cpan.org>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by The Network People, Inc..

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

