Dear friends, I am very new to perl but having lot of intrest to learn. I just tried the below
1. Reading records from database tables and dumping into file
2. Then formating as html page and uploading the data into html page
3. Then sending as email,when i open mail it should appear in the table format with that content. like below.
Name Address Number
The first two scripts are working fine. But when i run the mail script, it is coming to mail, but not as the expected formate(ie table) its coming as it is html tags and data mingeled. Can someone please help me how to correct this , and what needs to be added to fix this .
=================================================
#!/usr/contrib/bin/perl
open (HTML, ">/tmp/pperl/index.html");
print HTML "Content-Type: text/html\n\n";
print HTML "<html><head></head><body>";
print HTML "<table border=1>";
print HTML "<tr>";
print HTML "<td width=120 BGCOLOR=#ffff00>Name</td>";
print HTML "<td width=120 BGCOLOR=#ffff00>address</td>";
print HTML "<td width=120 BGCOLOR=#ffff00>number</td>";
print HTML "</tr>\n";
open(INPUTFILE,outfile);
open(HTML,">>/tmp/pperl/index.html");
while($line = <INPUTFILE> )
{
($xmit,$dc,$gcd)=split(/,/,$line);
print HTML "<tr>";
print HTML "<td>$Name</td>";
print HTML "<td>$address</td>";
print HTML "<td>$number</td>";
print HTML "</tr>";
}
close INPUTFILE;
print HTML "</table>";
print HTML "</body></html>";
close HTML;
=================================================
#!/usr/contrib/bin/perl
$to='asmas@xyz.com';
$from= 'asmas@xyz.com';
$subject='First perl HTML Mail test';
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Content-type: text/html\n\n";
open(FILE,"/tmp/pperl/index.html");
print MAIL <FILE>;
close (FILE);
close(MAIL);
==============================================================