From c0f603190406c37b2eb959803bfdb8087531c130 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 2 Dec 2009 23:11:25 +0000 Subject: [PATCH] FCKEditor always does UTF8, so force the Rmail encoding into that Also calculate the email TEXT from the email HTML, its not perfect but pretty darn good. TODO: need to do an update script that converts the encoding of ALL existing emails in the databse from ISO-8859-1 to UTF-8 DO NOT UPDATE TO THIS VERSION UNTIL I CAN ADD THAT CONVERSION SCRIPT --- admin/communication.php | 13 +++---------- common.inc.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/admin/communication.php b/admin/communication.php index f529cec..ad5ffce 100644 --- a/admin/communication.php +++ b/admin/communication.php @@ -158,15 +158,7 @@ case 'email_save': /* Allow the fundraising campaigns id to be NULL, it'll never be 0 */ $fcstr = ($fcid == 0) ? 'NULL' : "'$fcid'"; - //first, replace an

with


- $body=str_replace("

","


",$bodyhtml); - //now replace any
with newlines - $body=eregi_replace('',chr(13).chr(10),$body); - //and strip the rest of the tags - $body=strip_tags($body); - //and replace   - $body=str_replace(" "," ",$body); - + $body=getTextFromHtml($bodyhtml); mysql_query("UPDATE emails SET name='$name', description='$description', @@ -583,7 +575,8 @@ case 'dialog_sender': exit; case "email_send": - email_send_new($_POST['to'],$_POST['from'],$_POST['subject'],$_POST['body'],$_POST['bodyhtml']); + $body=getTextFromHtml($_POST['bodyhtml']); + email_send_new($_POST['to'],$_POST['from'],$_POST['subject'],$body,$_POST['bodyhtml']); happy_("Email Successfully Sent"); exit; diff --git a/common.inc.php b/common.inc.php index 34982ce..c1265b0 100644 --- a/common.inc.php +++ b/common.inc.php @@ -956,6 +956,8 @@ function email_send_new($to,$from,$subject,$body,$bodyhtml="") { $mail->setFrom($from); $mail->setSubject($subject); $mail->setText($body); + $mail->setTextCharset("utf-8"); + $mail->setHTMLCharset("utf-8"); //only add the html if we have it if($bodyhtml) { @@ -1265,5 +1267,17 @@ function format_duration($seconds, $granularity = 2) return $output ? $output : '0 sec'; } +function getTextFromHtml($html) { + //first, replace an

with


+ $text=str_replace("

","


",$html); + //now replace any
with newlines + $text=eregi_replace('',chr(13).chr(10),$text); + //and strip the rest of the tags + $text=strip_tags($text); + //and replace   + $text=str_replace(" "," ",$text); + return $text; +} + ?>