I am in the process of building a mailing list app which takes a text file that the user has uploaded and sends it out to a mailing stored in a database. I'm trying to make the subject equal the fifth line of the text file. I have grabbed the text file and put it in to an array like so:
<?
$filearray=file("$directory", "r");
$num = count($filearray);
$message="";
for($i=0; $i<$num; $i++)
$message .= "$filearray[$i]\n"; ?>
I then send out the the message to the mailing list like so:
<?
$email = (list of addresses from database)
$subject = $filearray[4];
$headers="";
$headers .= "From: ACPD<info@acpd.ca> \n";
$headers .= "X-Mailer: PHP\n"; $headers .= "X-Sender: <info@acpd.ca>\n";
$headers .= "X-Priority: 1\n";
$headers .= "Return-Path: ACPD<info@acpd.ca>\n";
mail($email, $subject, $message, $headers)
?>
It seems that when I set the $subject variable equal to the array filearray[] which holds the mesage it screws up all my headers and the message arrives with the wrong header info, but when I set the variable $subject to just a string it works fine. Does anyone know why this is happenning? Am I missing something?