solarcom
10-17-2006, 04:05 PM
:confused:
I have a script to send email with html, but when its recieved the email becoimes plain text and looks awful. Here's the code (the varibel "id" is passed from an earlier page)
$result = mysql_query("SELECT * FROM newsletters WHERE id='$id'");
while ($row = mysql_fetch_array($result, MYSQL_BOTH))
{
$subject = $row["name"];
$message = $row["content"];
$wwwtext = ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>$subject</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body>$message</body></html>");
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: newsletter@' . $_SERVER['SERVER_NAME'] . "\r\n" .
'Reply-To: newsletter@' . $_SERVER['SERVER_NAME'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$link = mysql_query("SELECT * FROM users WHERE status='subscribed'");
while ($r = mysql_fetch_array($link, MYSQL_BOTH))
{
$email = $r["email"];
$mail = mail($email, $subject, $wwwtext, $headers);
}
I have a script to send email with html, but when its recieved the email becoimes plain text and looks awful. Here's the code (the varibel "id" is passed from an earlier page)
$result = mysql_query("SELECT * FROM newsletters WHERE id='$id'");
while ($row = mysql_fetch_array($result, MYSQL_BOTH))
{
$subject = $row["name"];
$message = $row["content"];
$wwwtext = ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>$subject</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body>$message</body></html>");
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: newsletter@' . $_SERVER['SERVER_NAME'] . "\r\n" .
'Reply-To: newsletter@' . $_SERVER['SERVER_NAME'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$link = mysql_query("SELECT * FROM users WHERE status='subscribed'");
while ($r = mysql_fetch_array($link, MYSQL_BOTH))
{
$email = $r["email"];
$mail = mail($email, $subject, $wwwtext, $headers);
}