I am trying to get this simple script to work correctly, but I can't. The gist is to open a .txt file from the server, extract data from an array and then create seperate records through a loop and email the result away. Here's the script:
<?php
$percust= ''; {
$row = 1;
$handle = fopen ("orders.txt","r");
while ($data = fgetcsv ($handle, 1000, "|")) {
$num = count ($data);
print "<br><br>\n";
$row++;
for ($c=0; $c < 1; $c++) {
$message = ''; {
echo "A quick note from " . $data[5] . " at " . '<a href=' . $data[8] . '>' . $data[3] . '</a>' . ":" . "<br><br>\n";
echo "Dear " . $data[0] . " " . $data[1] . "," . "<br>\n";
echo "We wanted to let you know that your order from " . $data[3] . " " . "was shipped on " . $data[6] . ". Your " . $data[4] . " should arrive at your door in a short time. We truly value our customers and pride ourselves on our quality products and customer service. If you have any questions please fell free to contact Customer Service at (xxx) xxx-xxxx. They will be more than happy to assist you. <br><br>\n";
echo "We wanted to take a quick opportunity to tell you about another product you may enjoy. Our " . $data[7] . " is a very popular item on our site. Be sure to check it out at " . '<a href=' . $data[8] . '>' . $data[3] . '</a>' . ".<br><br>\n";
}
mail($data[2], 'A quick note from ' . $data[3].'', $message, "From:\"$data[5]\"<$data[3]> \rn");
}
}
fclose ($handle);
}
?>
Now when I load the page, the information (records) display correctly on the page, and emails are generated and sent, BUT, the body of the email ($message) doesn't show up in the email. What am I doing wrong? It is printed out on the screen, but not in the email.
I really appreciate any help.
Regards,
Eric