File Coverage

blib/lib/Siesta/Plugin/Bounce.pm
Criterion Covered Total %
statement 26 28 92.8
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 1 2 50.0
total 34 38 89.4


line stmt bran cond sub pod time code
1 3     3   2302 use strict;
  3         8  
  3         146  
2             package Siesta::Plugin::Bounce;
3 3     3   18 use Siesta::Plugin;
  3         8  
  3         33  
4 3     3   86 use base 'Siesta::Plugin';
  3         7  
  3         289  
5 3     3   3431 use Mail::DeliveryStatus::BounceParser;
  3         519696  
  3         59  
6              
7             # suggested usage set_plugins( bounce => qw( Bounce ) );
8              
9             sub description {
10 1     1 0 831 'simple bounce handler';
11             }
12              
13             sub process {
14 1     1 1 3 my $self = shift;
15 1         2 my $mail = shift;
16 1         13 my $list = $self->list;
17              
18 1         58 my $deferred = $mail->defer(who => $list->owner,
19             why => "bounce");
20              
21 1         60892 my $bounce = Mail::DeliveryStatus::BounceParser->new( $mail->as_string );
22 1         20840 my @addresses = grep { $_ } map { $_->get('email') } $bounce->reports;
  1         52  
  1         11  
23              
24 1         11 Siesta->log("bounce: ". $list->name . " " . join (', ', @addresses));
25              
26 1 50       4 if (grep { $_ eq $list->owner->email } @addresses) {
  1         8  
27             # deep deep badness
28 0         0 Siesta->log("holy shit, a listadmins mail is bouncing, so we can't tell them about it!");
29 0         0 return;
30             }
31 1         7021 $mail->reply( to => $list->owner->email,
32             subject => $list->name . " bouncing subscriber(s)",
33             body => join("\n", @addresses) );
34 1         219 return;
35             }
36              
37             1;