unless -f $template;
# A little big of prep.
-my $csv = Text::CSV_XS->new();
+my $csv = Text::CSV_XS->new({ binary => 1 });
my $tt = Template->new();
my $tmplData = undef;
last unless %$cols;
if ($verbose) {
- print "Template variables:\n";
+ print "\n\nTemplate variables:\n";
for my $key (sort keys %$cols) {
print "$key: $cols->{$key}\n";
}
# Do the merge.
my $out;
if (! $tt->process(\$tmplData->{'body'}, $cols, \$out)) {
- warn "Failed to process template: $tt->error()";
+ warn "Failed to process template: " . $tt->error();
warn "Template: $tmplData->{'body'}\n"
if $verbose;
print "\n\n";
}
+ my $bcc = $tmplData->{'bcc'};
+ my $cc = $tmplData->{'cc'};
if ($send) {
# If we're sending email, then send it, optionally with a BCC.
print "Sending to $cols->{'email'}" .
- ($tmplData->{'bcc'} ? " bcc $tmplData->{'bcc'} " : '') . "\n";
+ ($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'} );
From => $tmplData->{'from'},
Subject => $tmplData->{'subject'},
Bcc => $tmplData->{'bcc'},
+ Cc => $tmplData->{'bc'},
Encoding=> "quoted-printable",
Data => $out
);
$mail->send('sendmail');
} else {
# Say who we want to send to.
- print "Want to send to $cols->{'email'}" .
- ($tmplData->{'bcc'} ? " bcc $tmplData->{'bcc'} " : '') . "\n";
+ print "Want to send to: $cols->{'email'}" .
+ ($bcc ? "\n BCC " . (ref($bcc) eq 'ARRAY' ? join(", ", @{$bcc}) : $bcc) . " " : '') .
+ ($cc ? "\n CC " . (ref($cc) eq 'ARRAY' ? join(", ", @{$cc}) : $cc) . " " : '') . "\n";
}
}