We help IT Professionals succeed at work.

email the contents of a txt file

webmommy
webmommy asked
on
while(<EMAILADDRESSFILE>)
{
   open MAIL, "|mail " . $_;
   print MAIL $heading . $quote;
   close MAIL;
}

I want  $heading . $quote;  to be changed to the contents of a text file.  In other words, I want to have a text file sitting in the directory this script is in, and have that text file contain the body of my mass email, so I would be able to write something like

while(<EMAILADDRESSFILE>)
{
   open MAIL, "|mail " . $_;
   print MAIL [a filename];
   close MAIL;
}

Help! I need a solution quick.
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015
Commented:
open MAIL, "|mail " . $_;
open FILE,"<a filename" or die "can't open a filename $!";
print MAIL <FILE>;
close MAIL;
close FILE

Explore More ContentExplore courses, solutions, and other research materials related to this topic.