close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

utf-8

Thread began 12/19/2016 12:25 pm by JBWebWorks | Last modified 12/22/2016 5:35 pm by Ray Borduin | 2658 views | 6 replies |

JBWebWorks

utf-8

I have changed the smtp char set to utf-8 and in my server php.ini changed my default_charset to utf-8 but when i send email with ' or " or / in the mail body, I see \' or \" or /\ or even ’

I have also changed the apache default char

The email body comes from a text area that uses JavaScript for a rich text editor; don't know if that affects the setting for utf-8?

Including code from pages

php:
<?php

$MailAttachments 
"";
$MailBCC         "";
$MailCC          "";
$MailTo          "";
$MailBodyFormat  "";
$MailBody        "";
$MailImportance  "";
$MailFrom        "".((isset($_POST["from1"]))?$_POST["from1"]:"")  ."";
$MailSubject     "".((isset($_POST["subject1"]))?$_POST["subject1"]:"")  ."";
$_SERVER["QUERY_STRING"] = "";

//Global Variables

  
$WA_MailObject WAUE_Definition("","","","","","UTF-8");

if (
$RecipientEmail)     {
  
$WA_MailObject WAUE_AddRecipient($WA_MailObject,$RecipientEmail);
}
else      {
  
//To Entries
}

//Additional Headers

//Attachment Entries
  
$WA_MailObject WAUE_AddAttachment($WA_MailObject,"".(AttachFromUpload("attach"))  ."");

//BCC Entries

//CC Entries

//Body Format
  
$WA_MailObject WAUE_BodyFormat($WA_MailObject,0);

//Set Importance
  
$WA_MailObject WAUE_SetImportance($WA_MailObject,"3");

//Start Mail Body
$MailBody $MailBody "<html><head></head><body><br />\r\n";
$MailBody $MailBody .  ((isset($_POST["message1"]))?$_POST["message1"]:"");
$MailBody $MailBody "</body></html>";
//End Mail Body

$WA_MailObject WAUE_SendMail($WA_MailObject,$MailAttachments,$MailBCC,$MailCC,$MailTo,$MailImportance,$MailFrom,$MailSubject,$MailBody,"waue_emailgroup_1");

if (isset(
$GLOBALS["waue_emailgroup_1_Status"])) {
  
$MailLogBindings = new WAUE_Log_Bindings();
  
//Start Log Bindings
  //End Log Bindings
  
$MailLogBindings->SuccessOrFailure->MailRef "waue_emailgroup_1";
  
$MailLogBindings->Success->MailRef "waue_emailgroup_1";
  
$MailLogBindings->Failure->MailRef "waue_emailgroup_1";
  
$MailLogBindings->processLog(($GLOBALS["waue_emailgroup_1_Status"] == "Failure"));
}
$WA_MailObject null;
?>



code from page that generates the email

php:
<?php require_once('Connections/connmpmga1.php'); ?>

<?php 
require_once( "webassist/security_assist/helper_php.php" ); ?>
<?php
if (!WA_Auth_RulePasses("Logged in to admin")){
    
WA_Auth_RestrictAccess("admin_login.php");
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

mysql_select_db($database_connmpmga1$connmpmga1);
$query_rs_members "SELECT members.EmailAddress FROM members";
$rs_members mysql_query($query_rs_members$connmpmga1) or die(mysql_error());
$row_rs_members mysql_fetch_assoc($rs_members);
$totalRows_rs_members mysql_num_rows($rs_members);
?>
<?php 
require_once("webassist/email/mail_php.php"); ?>
<?php 
require_once("webassist/email/mailformatting_php.php"); ?>
<?php
if ((isset($_POST["submit1"]) || isset($_POST["submit1_x"])))     {
  
//WA Universal Email object="mail"
  
@session_write_close();
  @
set_time_limit(0);
  
$EmailRef "waue_emailgroup_1";
  
$BurstSize 50;
  
$BurstTime 1;
  
$WaitTime 1;
  
$GoToPage "?success=true";
  
$RecipArray = array();
  
$StartBurst time();
  
$LoopCount 0;
  
$TotalEmails 0;
  
$RecipIndex 0;
  
// build up recipients array
  
$CurIndex sizeof($RecipArray);
  
$RecipArray[$CurIndex] = array();
  
$RecipArray[$CurIndex][] = $row_rs_members;
  
$RecipArray[$CurIndex][] = $rs_members;
  
$RecipArray[$CurIndex][] = "EmailAddress";
  
$TotalEmails += mysql_num_rows($rs_members);
  
$RealWait = ($WaitTime<0.25)?0.25:($WaitTime+0.1);
  
$TimeTracker = Array();
  
$TotalBursts floor($TotalEmails/$BurstSize);
  
$AfterBursts $TotalEmails $BurstSize;
  
$TimeRemaining = ($TotalBursts $BurstTime) + ($AfterBursts*$RealWait);
  if (
$TimeRemaining < ($TotalEmails*$RealWait) )  {
    
$TimeRemaining $TotalEmails*$RealWait;
  }
  
writeUEProgress($EmailRef,0,$TotalEmails,$TimeRemaining);
  while (
$RecipIndex sizeof($RecipArray))  {
    
$EnteredValue is_string($RecipArray[$RecipIndex][0]);
    
$CurIndex 0;
    while ((
$EnteredValue && $CurIndex sizeof($RecipArray[$RecipIndex])) || (!$EnteredValue && $RecipArray[$RecipIndex][0])) {
      
$starttime microtime_float();
      if (
$EnteredValue)  {
        
$RecipientEmail $RecipArray[$RecipIndex][$CurIndex];
      }  else  {
        
$RecipientEmail $RecipArray[$RecipIndex][0][$RecipArray[$RecipIndex][2]];
      }
      
$EmailsRemaining = ($TotalEmails$LoopCount);
      
$BurstsRemaining ceil(($EmailsRemaining-$AfterBursts)/$BurstSize);
      
$IntoBurst = ($EmailsRemaining-$AfterBursts) % $BurstSize;
      if (
$AfterBursts<$EmailsRemaining$IntoBurst 0;
      
$TimeRemaining = ($BurstsRemaining $BurstTime 60) + ((($AfterBursts<$EmailsRemaining)?$AfterBursts:$EmailsRemaining)*$RealWait) - (($AfterBursts>$EmailsRemaining)?0:($IntoBurst*$RealWait));
      if (
$TimeRemaining < ($EmailsRemaining*$RealWait) )  {
        
$TimeRemaining $EmailsRemaining*$RealWait;
      }
      
$CurIndex ++;
      
$LoopCount ++;
      
writeUEProgress($EmailRef,$LoopCount,$TotalEmails,round($TimeRemaining));
      
wa_sleep($WaitTime);
      include(
"webassist/email/waue_emailgroup_1.php");
      
$endtime microtime_float();
      
$TimeTracker[] =$endtime $starttime;
      
$RealWait array_sum($TimeTracker)/sizeof($TimeTracker);
      if (
$LoopCount $BurstSize == && $CurIndex sizeof($RecipArray[$RecipIndex]))  {
        
$TimePassed = (time() - $StartBurst);
        if (
$TimePassed < ($BurstTime*60))  {
          
$WaitBurst = ($BurstTime*60) -$TimePassed;
          
wa_sleep($WaitBurst);
        }
        else  {
          
$TimeRemaining = ($TotalEmails$LoopCount)*$RealWait;
        }
        
$StartBurst time();
      }
      if (!
$EnteredValue)  {
        
$RecipArray[$RecipIndex][0] =  mysql_fetch_assoc($RecipArray[$RecipIndex][1]);
      }
    }
    
$RecipIndex ++;
  }
  @
session_start();
  
$_SESSION[$EmailRef."_Status"] = $GLOBALS[$EmailRef."_Status"];
  
$_SESSION[$EmailRef."_Index"] = $GLOBALS[$EmailRef."_Index"];
  
$_SESSION[$EmailRef."_From"] = $GLOBALS[$EmailRef."_From"];
  
$_SESSION[$EmailRef."_To"] = $GLOBALS[$EmailRef."_To"];
  
$_SESSION[$EmailRef."_Subject"] = $GLOBALS[$EmailRef."_Subject"];
  
$_SESSION[$EmailRef."_Body"] = $GLOBALS[$EmailRef."_Body"];
  
$_SESSION[$EmailRef."_Header"] = $GLOBALS[$EmailRef."_Header"];
  
$_SESSION[$EmailRef."_Log"] = $GLOBALS[$EmailRef."_Log"];
  if (
function_exists("rel2abs")) $GoToPage $GoToPage?rel2abs($GoToPage,dirname(__FILE__)):"";
  if (
$GoToPage!="")     {
    
header("Location: ".$GoToPage);
  }
}
?>


and this is the javascript for the rich text box
<div id="sample">

<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> <script type="text/javascript">

//<![CDATA[

bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });

//]]>
</script>



</div>

Sign in to reply to this post

Ray BorduinWebAssist

Are you setting the charset on the page as well in the head like:

<meta charset="UTF-8">
Sign in to reply to this post
Did this help? Tips are appreciated...

JBWebWorks

Ray,

Yes I have this on the page that generates the emails

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Sign in to reply to this post

Ray BorduinWebAssist

If you give me FTP access I can try to track it down. I think you can specify the language in the editor as well, but I forget where. I'd try adding a textarea and see if it has the same problem to narrow down if it has something to do with the editor or not.

Sign in to reply to this post
Did this help? Tips are appreciated...

JBWebWorks

Ray,
I did try with a plain textarea and had the same problem.
The page sends dynamically to about 100 email addresses.
See PM for ftp info

Sign in to reply to this post

Ray BorduinWebAssist

You have "magic_quotes_gpc" enabled on your server. This is a horrible and deprecated feature that can cause issues like these. I'd suggest turning it off if possible, but I've also added a script to the top of your page that will undo the mess magic quotes causes.

Sign in to reply to this post
Did this help? Tips are appreciated...

JBWebWorks

Ray,
Thanks for your support. I tested and it fixed my email problems.
I will disable magic_quotes_gpc.

Merry Christmas and Happy New Year to you and Webassist!

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...