From: Andrew Ruthven Date: Tue, 1 Dec 2009 09:28:56 +0000 (+1100) Subject: Look for both email and email_address in the YML file. X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4726525a10c1d37cac2be5f4d99db75b37d64a60;p=mail-merge.git Look for both email and email_address in the YML file. --- diff --git a/merge.pl b/merge.pl index 39844e3..40ba3d8 100755 --- a/merge.pl +++ b/merge.pl @@ -97,13 +97,15 @@ while (my $cols = $csv->getline_hr($IN) ) { my $bcc = $tmplData->{'bcc'}; my $cc = $tmplData->{'cc'}; + my $email_address = $cols->{'email'} || $cols->{'email_address'}; if ($send) { + # If we're sending email, then send it, optionally with a BCC. - print "Sending to $cols->{'email'}" . + print "Sending to $email_address" . ($bcc ? "\n BCC " . (ref($bcc) eq 'ARRAY' ? join(", ", @{$bcc}) : $bcc) . " " : '') . ($cc ? "\n cC " . (ref($cc) eq 'ARRAY' ? join(", ", @{$cc}) : $cc) . " " : '') . "\n"; - my @emails = ( $cols->{'email'} ); + my @emails = ( $email_address ); my $mail = MIME::Entity->build( To => \@emails, @@ -118,7 +120,7 @@ while (my $cols = $csv->getline_hr($IN) ) { $mail->send('sendmail'); } else { # Say who we want to send to. - print "Want to send to: $cols->{'email'}" . + print "Want to send to: $email_address" . (defined $bcc ? "\n BCC " . (ref($bcc) eq 'ARRAY' ? join(", ", @{$bcc}) : $bcc) . " " : '') . (defined $cc ? "\n CC " . (ref($cc) eq 'ARRAY' ? join(", ", @{$cc}) : $cc) . " " : '') . "\n"; }