Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Encoding problem with email subject line


Reply


2 Posts   2127 Views

Avatar
cliersch

Community Member, 75 Posts

7 March 2009 at 6:53am

Hi! Does anybody knows about the email function and the encoding problem?

I've got a problem with the encoding of the subject line of my send emails.

It's possible to send an email in utf-8. The body of the email is correctly encoded.
But it's not working for the "subject" header of the email. I'm receiving broken encoding.

Something might be wrong with the email header.

Any idea?

Avatar
denisrosset

Community Member, 4 Posts

11 January 2010 at 11:20pm

Dear all,

I am having the same issue. I don't understand which encoding to use to send email subjects from Silverstripe.

As a temporary measure, I use the following function to remove most common French characters, but I would like to know how to proceed.

Warm regards,

Denis

   function removeAccents($remove_from)
   {
      // Remove all instances of accents
      $accent_array = array('e' => array('é','è','ê','ë'),
       'E' => array('É','È','Ê','Ë'),
       'a' => array('á','à','â','ä','Ã¥'),
       'A' => array('Á','À','Â','Ä','Ã…'),
       'i' => array('ï','ì','î'),
       'I' => array('Ï','ÃŒ','ÃŽ'),
       'o' => array('ö','ô','ò'),
       'O' => array('Ö','Ô','Ã’'),
       'u' => array('ü','û','ù'),
       'U' => array('Ãœ','Û','Ù')
       );
      foreach($accent_array as $acc_key => $acc_val_array)
         {
            $reg_exp_accent = '';// clear regular expression var
            for($m=0;$m<count($acc_val_array);$m++)
               {
                  $reg_exp_accent .= $acc_val_array[$m].'|';// create the regular expression var
               }
            $reg_exp_accent = substr_replace($reg_exp_accent,"",-1);// remove last '|'
            
            $remove_from = ereg_replace($reg_exp_accent,$acc_key,$remove_from);
         }
      return $remove_from;
   }