LD SoftwareBespoke Software, Web Design, Security Consultants and Host Services.

Menu

Sentinel
You have been warned!
We have caught 5883 shameful hackers.

NukeSentinel(tm)

Paypal Referral
Sign up for PayPal and start accepting credit card payments instantly.

Link Exchange
Join our free link exchange

Click Here
 
How to allow HTML in the Newsletter

19.2. How to allow HTML in the Newsletter

Figure 19-3. Administration panel: Newsletter.

Administration panel: 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.

 
You can syndicate our News with backend.php And our Forums with rss.php
You can also access our feeds via Feedburner Site News and LD Software Forums
© 2009 ld-software.co.uk All Rights Reserved.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.15 Seconds