Hi,
I am trying to create a mailing list, and have two files called 'message.php' and 'sendMail.php'.
'message.php' is just an html document with embedded php coding.
'sendMail.php', has the mail() script (which works), and a function to import the lines from 'message.php', into a variable, which imports everything fine, except the php isn't executed. I have tried a few different methods for importing 'message.php' like:
// 'sendMail.php'
// Method one
$handle = fopen ("message.php", "r");
while (!feof ($handle)) {
$buffer .= fgets($handle, 4096);
}
fclose ($handle);
$message = $buffer;
$mailSent = mail($recipients, $subject, $message, $headers);
if ($mailSent) {
echo "<p>Mail was sent successfully</p>\n";
}else{
echo "<p>Mail was not sent</p>\n";
}
// Method two
$file = 'message.php';
$message = join('', ($file));
$mailSent = mail($recipients, $subject, $message, $headers);
if ($mailSent) {
echo "<p>Mail was sent successfully</p>\n";
}else{
echo "<p>Mail was not sent</p>\n";
}
Both of these functions import all of the text in the external file, but don't execute the php inside it, so is there another way to import the external file to mail that executes the php inside it?
Hope that made sense
Thanks
Ste