Moderators: Dragonrider, J_S, Hernol, vancoovur, H2B2, Heritage
function sendMailPhpMailer ($to,$subject,$message) {
# global function to capture sending emails, to avoid trouble with
# older (and newer!) php versions
$fromemail = getConfig("message_from_address");
$fromname = getConfig("message_from_name");
$message_replyto_address = getConfig("message_replyto_address");
if ($message_replyto_address)
$reply_to = $message_replyto_address;
else
$reply_to = $from_address;
$destinationemail = '';
// customisation to allow HTML in system messages
$html_message = $message;
$message = preg_replace('/(<script.*\/script>)|(<style.*\/style>)/i', '', $message);
$message = preg_replace('/<a\s*.*?href\s*=\s*("|\')([^"\']*?)("|\').*?>(.*?)<\/a>/i', "$4:\n$2\n", $message);
$message = strip_tags($message);
// end customisation
if (!ereg("dev",VERSION)) {
$mail = new PHPlistMailer('systemmessage',$to);
$destinationemail = $to;
$mail->add_html($html_message); // customisation
$mail->add_text($message);
} else {
# send mails to one place when running a test version
$message = "To: $to\n".$message;
if ($GLOBALS["developer_email"]) {
# fake occasional failure
if (mt_rand(0,50) == 1) {
return 0;
} else {
$mail = new PHPlistMailer('systemmessage',$GLOBALS["developer_email"]);
$mail->add_html($html_message); // customisation
$mail->add_text($message);
$destinationemail = $GLOBALS["developer_email"];
}
} else {
print "Error: Running CVS version, but developer_email not set";
}
}
$mail->build_message(
array(
"html_charset" => getConfig("html_charset"),
"html_encoding" => HTMLEMAIL_ENCODING,
"text_charset" => getConfig("text_charset"),
"text_encoding" => TEXTEMAIL_ENCODING)
);
return $mail->send("", $destinationemail, $fromname, $fromemail, $subject);
}
You just need to make some modifications to the sendMailPhpMailer() function in the /admin/lib.php file. Once this is done, simply enter the raw html you want into the fields for 'Message users receive when they subscribe' etc. You can also enter HTML for any of the system emails that can be edited on the configuration page.
EvilPuppetMaster wrote:This is for 2.10.2, haven't tested in 2.10.3. No guarantees that it won't break anything, use at your own risk and test thoroughly!
You just need to make some modifications to the sendMailPhpMailer() function in the /admin/lib.php file. Once this is done, simply enter the raw html you want into the fields for 'Message users receive when they subscribe' etc. You can also enter HTML for any of the system emails that can be edited on the configuration page. The script will automatically send both html and text only versions of the email, for those email clients that don't support HTML. Note that the text-only version is made by simply stripping all the html tags so it won't look pretty unless you take care that the message still has line breaks in the right place when the html is stripped.
Anyway, on to the code!
In /admin/lib.php, find the sendMailPhpMailer() function, about line 246, and change it to the below. Lines that I've changed from the original have been commented with //customisation:
- Code: Select all
function sendMailPhpMailer ($to,$subject,$message) {
# global function to capture sending emails, to avoid trouble with
# older (and newer!) php versions
$fromemail = getConfig("message_from_address");
$fromname = getConfig("message_from_name");
$message_replyto_address = getConfig("message_replyto_address");
if ($message_replyto_address)
$reply_to = $message_replyto_address;
else
$reply_to = $from_address;
$destinationemail = '';
// customisation to allow HTML in system messages
$html_message = $message;
$message = preg_replace('/(<script>)|(<style>)/i', '', $message);
$message = preg_replace('/<a>(.*?)</a>/i', "$4:\n$2\n", $message);
$message = strip_tags($message);
// end customisation
if (!ereg("dev",VERSION)) {
$mail = new PHPlistMailer('systemmessage',$to);
$destinationemail = $to;
$mail->add_html($html_message); // customisation
$mail->add_text($message);
} else {
# send mails to one place when running a test version
$message = "To: $to\n".$message;
if ($GLOBALS["developer_email"]) {
# fake occasional failure
if (mt_rand(0,50) == 1) {
return 0;
} else {
$mail = new PHPlistMailer('systemmessage',$GLOBALS["developer_email"]);
$mail->add_html($html_message); // customisation
$mail->add_text($message);
$destinationemail = $GLOBALS["developer_email"];
}
} else {
print "Error: Running CVS version, but developer_email not set";
}
}
$mail->build_message(
array(
"html_charset" => getConfig("html_charset"),
"html_encoding" => HTMLEMAIL_ENCODING,
"text_charset" => getConfig("text_charset"),
"text_encoding" => TEXTEMAIL_ENCODING)
);
return $mail->send("", $destinationemail, $fromname, $fromemail, $subject);
}
Return to Add-ons, Contributions, Mods, Plug-ins
Users browsing this forum: No registered users and 0 guests