Add basic bounce score calculation and reporting.
This commit is contained in:
parent
ddaaebe6a0
commit
40ba318fac
4 changed files with 70 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ sub handler {
|
|||
my $class =
|
||||
$module eq 'manage' ? 'WebGUI::Mailing::Admin'
|
||||
: $module eq 'mailing' ? 'WebGUI::Mailing'
|
||||
: $module eq 'bounce' ? 'WebGUI::Mailing::Bounce'
|
||||
: return
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ sub getAdminConsole {
|
|||
my $url = $session->url;
|
||||
|
||||
my $ac = WebGUI::AdminConsole->new( $session );
|
||||
|
||||
$ac->addSubmenuItem( $url->page( 'newsletter=manage' ), 'Manage mailings' );
|
||||
$ac->addSubmenuItem( $url->page( 'newsletter=manage;func=settings' ), 'Newsletter settings' );
|
||||
$ac->addSubmenuItem( $url->page( 'newsletter=bounce;func=bounceReport' ), 'Bounce scores' );
|
||||
|
||||
return $ac;
|
||||
}
|
||||
|
|
|
|||
58
lib/WebGUI/Mailing/Bounce.pm
Normal file
58
lib/WebGUI/Mailing/Bounce.pm
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package WebGUI::Mailing::Bounce;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WebGUI::Mailing::Admin;
|
||||
|
||||
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 $sth = $session->db->read( 'select distinct sentTo from WGMailing_queue where sentTo is not null' );
|
||||
|
||||
my $output = '<table><tr><th>Email</th><th>Bounce score</th></tr>';
|
||||
while ( my ($email) = $sth->array ) {
|
||||
my $score = $self->getBounceScore( $email );
|
||||
$output .= "<tr><td>$email</td><td>$score</td></tr>";
|
||||
}
|
||||
$output .= '</table>';
|
||||
|
||||
return WebGUI::Mailing::Admin->new( $session )->getAdminConsole->render( $output, 'Bounce score overview' );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -1,5 +1,12 @@
|
|||
#!/data/wre/prereqs/bin/perl
|
||||
|
||||
BEGIN {
|
||||
unshift @INC, qw(
|
||||
/data/custom/webgui_newsletter/lib
|
||||
/data/WebGUI/lib
|
||||
);
|
||||
}
|
||||
|
||||
use strict;
|
||||
|
||||
use Mail::DeliveryStatus::BounceParser;
|
||||
|
|
@ -12,12 +19,6 @@ my %configs = (
|
|||
'martintwee.oqapi.nl' => 'martintwee.oqapi.nl.conf',
|
||||
);
|
||||
|
||||
BEGIN {
|
||||
unshift @INC, qw(
|
||||
/data/custom/webgui_newsletter/lib
|
||||
/data/WebGUI/lib
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue