- Readme First! - Read and follow the rules, otherwise your posts will be closed
There are currently, 141 guest(s) and 0 member(s) that are online. You are Anonymous user. You can register for free by clicking here
How to allow HTML in the Newsletter
If you want to use HTML, instead of only plain text in the Newsletter from the administration panel, you have to do the following:
Replace the function newsletter_send() in admin/modules/newsletter.php with:
function newsletter_send($title, $content) {
global $user_prefix, $sitename, $dbi, $nukeurl, $adminmail;
$send_html_messages = "yes";
$from = $adminmail;
$subject = "[$sitename Newsletter]: ".stripslashes($title)."";
$content = stripslashes($content);
$content = "$sitename "._NEWSLETTER."\n\n\n$content\n\n-
$sitename "._STAFF."\n\n\n\n\n\n"._NLUNSUBSCRIBE."";
$result = sql_query("select email from ".$user_prefix.
"_users where newsletter='1'", $dbi);
while(list($email) = sql_fetch_row($result, $dbi)) {
$xheaders = "From: " . $sitename . " <" . $adminmail . ">\n";
$xheaders .= "X-Sender: <" . $adminmail . ">\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 6\n"; // Urgent message!
if ($send_html_messages == "yes") {
$xheaders .= "Content-Type: text/html;
charset=iso-8859-1\n"; // Mime type
}
mail("$email","$subject","$content",$xheaders);
}
Header("Location: admin.php?op=newsletter_sent");
}
and the function massmail_send() with
function massmail_send($title, $content) {
global $user_prefix, $sitename, $dbi, $nukeurl, $adminmail;
$send_html_messages = "yes";
$from = $adminmail;
$subject = "[$sitename]: $title";
$content = stripslashes($content);
$content = ""._FROM.": $sitename\n\n\n\n$content\n\n\n\n-
$sitename "._STAFF."\n\n\n\n"._MASSEMAILMSG."";
$result = sql_query("select email from ".$user_prefix
."_users where uid != '1'", $dbi);
while(list($email) = sql_fetch_row($result, $dbi)) {
$xheaders = "From: " . $sitename . " <" . $adminmail . ">\n";
$xheaders .= "X-Sender: <" . $adminmail . ">\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 6\n"; // Urgent message!
if ($send_html_messages == "yes") {
$xheaders .= "Content-Type: text/html;
charset=iso-8859-1\n"; // Mime type
}
mail("$email","$subject","$content",$xheaders);
}
Header("Location: admin.php?op=massmail_sent");
}
The changes are in both functions the same: a flag, $send_html_messages, is checked and if set to "yes", the headers of the Newsletter mails (stored in the $xheaders variable) get an extra line
for the MIME type:
Content-Type: text/html; charset=iso-8859-1
See also HTML Newsletter , but be warned that the code presented in that link, may not escape double quotes, probabbly due to an
upgrade bug in the forums.