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
This commit is contained in:
james 2009-12-02 23:11:25 +00:00
parent 148bc61320
commit c0f6031904
2 changed files with 17 additions and 10 deletions

View File

@ -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 </p> with </p><br />
$body=str_replace("</p>","</p><br />",$bodyhtml);
//now replace any <br /> with newlines
$body=eregi_replace('<br[[:space:]]*/?[[:space:]]*>',chr(13).chr(10),$body);
//and strip the rest of the tags
$body=strip_tags($body);
//and replace &nbsp;
$body=str_replace("&nbsp;"," ",$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;

View File

@ -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 </p> with </p><br />
$text=str_replace("</p>","</p><br />",$html);
//now replace any <br /> with newlines
$text=eregi_replace('<br[[:space:]]*/?[[:space:]]*>',chr(13).chr(10),$text);
//and strip the rest of the tags
$text=strip_tags($text);
//and replace &nbsp;
$text=str_replace("&nbsp;"," ",$text);
return $text;
}
?>