I am sending html emails and here is the code:
<?
$sql_emails = "SELECT * FROM emails";
$emailextract = mysql_query($sql_emails,$connection) or die(mysql_error());
while ($rowEmail = mysql_fetch_array($emailextract)) {
$subject = $rowEmail['subject'];
$from_address = $rowEmail['from_address'];
$html_email_content = $rowEmail['html_email_content'];
}
$to = $email;
$subject = $subject;
$message = $html_email_content; // this is the problem here!
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: ' . $from_address . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
}
?>
It's actually not giving me any problems with sending emails. I simply query the database for email content.
Here is what my "emails" table is holding for html_email_content.
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr>
<td>Dear %CUSTOMER% </td>
</tr>
<tr>
<td>Blah Blah Blah</td>
</tr>
</table>
</body>
</html>
My question concerns the part: %CUSTOMERS%. I want to insert the of all the customer names here. I have the email in a loop, so each email address in another table gets sent the message above.
Here's the catch, I am viewing and editing this html email with a wysiwyg editor. If I put the code manually inside a php file and placed the First Name & Last Name variables there, then it works. But I want to be able to place some global markers such as: %ADDRESS%, %CITY%, %ZIP%, etc..... inside the editor window, and let the PHP understand what I want there.
But, I'm having a terrible time figuring out how to insert the customer name, or anything there.
Any thoughts?