package WebGUI::Mailing::Bounce; use strict; use warnings; use WebGUI::Mailing::Admin; #---------------------------------------------------------------------------- sub bounceScoreOk { my $self = shift; my $address = shift; my $setting = $self->session->setting; my $threshold = $setting->get('newsletterBounceScoreThreshold'); return 1 unless $threshold; return $self->getBounceScore( $address ) < $threshold; } #---------------------------------------------------------------------------- sub getBounceScore { my $self = shift; my $address = shift; my $session = $self->session; my $it = WebGUI::Mailing::Email->getAllIterator( $session, { constraints => [ { 'sentTo=?' => [ $address ] }, { 'status<>?' => [ 'queued' ] }, ], orderBy => 'sendDate desc', limit => 10, } ); my $score = 0; while ( my $email = $it->() ) { $score += 1 if $email->get('status') eq 'bounced'; } return $score; } #---------------------------------------------------------------------------- sub new { my $class = shift; my $session = shift; bless { _session => $session }, $class; } #---------------------------------------------------------------------------- sub session { return (shift)->{ _session }; } #---------------------------------------------------------------------------- sub www_bounceReport { my $self = shift; my $session = $self->session; my $i18n = WebGUI::International->new( $session, 'MailingManager' ); my $sth = $session->db->read( 'select distinct sentTo from Mailing_email where sentTo is not null' ); my $output = '
| '.$i18n->get('email').' | '.$i18n->get('bounce score').' |
|---|---|
| $score |