Gavin Henry wrote:
Dear all,use slurp method to get all the text of a file into a variable.. my $message;
I have the following:
#!/usr/bin/perl use strict; use warnings; use Mail::Sendmail;
my $from = '"Test e-mails" <[EMAIL PROTECTED]>'; my $subject = 'Testing for survey e-mail';
open LIST, "<mailinglist" or die "Cannot open mailing list: $!";
open MESSAGE, "<mailinglist-message" or die "Cannot open mailing list message: $!";
my $message = <MESSAGE>;
foreach (<LIST>) {
my %mails = ( To => "$_",
From => "$from",
Subject => "$subject",
Message => "$message",
);
sendmail(%mails) or die $Mail::Sendmail::error;
print "Message has been sent to $_"; };
close LIST; close MESSAGE; print "All e-mails sent successfully.\n\n";
1. How can I get my whole email message into Message => 2. I think my filehanldes are messess, can you suggest anything? 3. my $message = <MESSAGE>; only gives the first line?
Thanks,
G.
{
local $/ = undef; #$/ is the input field separator.. By default $/ = "\n".. By undefining it you are able to convert the whole file to a single field.
$message = <MESSAGE>;
}
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>