Permalink
Browse files

break apart multiple email addresses into separate ones

  • Loading branch information...
1 parent 34ef429 commit 5fc611cc0c3400331111ee442ba1c41790b40369 Luke Closs committed Mar 26, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 bin/job-runner
View
@@ -20,10 +20,13 @@ my $daemon = Biopay::Daemon->new(
'send-email' => sub {
my $args = shift->args->{msg};
print " (Sending '$args->{subject}' email to $args->{to}) ";
- email {
- from => config->{email_from},
- %$args,
- };
+ for my $to (parse_email(delete $args->{to})) {
+ email {
+ from => config->{email_from},
+ to => $to,
+ %$args,
+ };
+ }
},
'email-all-members' => sub {
my ($job, $member) = @_;
@@ -56,6 +59,14 @@ my $daemon = Biopay::Daemon->new(
$daemon->run;
exit;
+sub parse_email {
+ my $email = shift || return ();
+ $email =~ s/^\s+//;
+ $email =~ s/\s+$//;
+ my @addrs = split m/\s+/, $email;
+ return @addrs;
+}
+
sub email_all_members {
my $args = shift;
my $subj = $args->{subj} || die "send_email: subj is not defined!";
@@ -66,7 +77,7 @@ sub email_all_members {
my $members = shift;
my %emails = map { $_ => 1 }
grep { length } grep { defined }
- map { $_->email }
+ map { parse_email($_->email) }
grep { $_->active and !$_->email_optout }
@$members;
print " (Sending '$subj' to: ";

0 comments on commit 5fc611c

Please sign in to comment.