aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-10-28 11:15:43 +0000
committerStruan Donald <struan@exo.org.uk>2013-10-28 11:15:43 +0000
commit9d9359195f23a1426d94f85f0028b03d7cd522d1 (patch)
treea245aac05c2757bbbaae69f902c2984a8405a038
parent09ae8314da546d52b746281c27cb6f0cc3e202ba (diff)
change email sender to handle multiple emails per contact
splits emails on comma WIP
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm16
1 files changed, 13 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index 9006e2f11..21f8f7ca0 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -33,14 +33,24 @@ sub build_recipient_list {
$self->unconfirmed_notes->{$body_email}{$row->category} = $note;
}
+ my $body_name = $body->name;
# see something uses council areas but doesn't send to councils so just use a
# generic name here to minimise confusion
if ( $row->cobrand eq 'seesomething' ) {
- push @{ $self->to }, [ $body_email, 'See Something, Say Something' ];
+ $body_name = 'See Something, Say Something';
+ }
+
+ my @emails;
+ # allow multiple emails per contact
+ if ( $body_email =~ /,/ ) {
+ @emails = split(/,/, $body_email);
} else {
- push @{ $self->to }, [ $body_email, $body->name ];
+ @emails = ( $body_email );
+ }
+ for my $email ( @emails ) {
+ push @{ $self->to }, [ $email, $body_name ];
+ $recips{$email} = 1;
}
- $recips{$body_email} = 1;
}
return () unless $all_confirmed;