I have an html email message assigned to a variable before it is used in a loop, then in the loop I try to use str_replace to insert custom values into hooks. So in the below example I have an {email} hook which I'm trying to replace with the recipient's email address. My problem is that when I output $message_final to the browser the str_replace function seems to have done the job. But when I send the email out, all the emails are still left with the {email} hook, and it appears that str_replace hasn't worked. Any ideas what i'm missing here? Thanks.
$message = "HTML email message here";
while ($r = mysql_fetch_array($emails_list)) {
$email = $r["email"];
$message_final = "";
if(!empty($email)) {
//Replace hook with something new like an email address
$message_final = str_replace('{email}', $email, $message);
mail($email, $subject, $message_final, $headers);
}
}
$messagethat contains the hooks?var_dump()you used to see the message in your browser)?