Welcome Guest, Not a member yet? Register   Sign In
french email subject lines not working
#1

[eluser]Riley123[/eluser]
Using latest CI.

Email sends as html fine, but my subject lines are getting some garbage characters when they contain french accents.

Also the email fails if the subject line is too long.

What is the limitation of characters allowed in a subject length and how do I display properly french characters? I am using utf-8.


--
R
#2

[eluser]Riley123[/eluser]
ok some progress.

I changed email config to $config['charset'] = 'iso-8859-1';

then i convert this following string to htmlentities:

"Découvre ton style de décor pour une chance de gagner!"

that gives me:

Découvre ton style de décor pour une chance de gagner!

then

$pSubject = mb_convert_encoding("Découvre ton style de décor pour une chance de gagner!", 'iso-8859-1', 'HTML-ENTITIES');

This works for showing the proper characters in the email subject line, but the text is too long and won't send. If i have less than 50 characters it works. Is this a bug???

What is the limitation of characters in the email subject line? Is it really only 50???


--
R
#3

[eluser]Riley123[/eluser]
ok an update. Below is the code.

This line will say sent in debugger but won't get sent. "Découvre ton style de décor pour une chance de gagner!";
This line with less characters sends fine. "Découvre ton style de décor"

Any ideas if this is a bug or I'm missing something?

my code

$pSubject = "Découvre ton style de décor pour une chance de gagner!";
$pSubject = convertLatin1ToHtml($pSubject);
$pSubject = mb_convert_encoding($pSubject, 'iso-8859-15', 'HTML-ENTITIES');

and this helper function

function convertLatin1ToHtml($str) {
$html_entities = array (
"&" => "&", #ampersand
"á" => "á", #latin small letter a
"Â" => "Â", #latin capital letter A
"â" => "â", #latin small letter a
"Æ" => "Æ", #latin capital letter AE
"æ" => "æ", #latin small letter ae
"À" => "À", #latin capital letter A
"à" => "à", #latin small letter a
"Å" => "Å", #latin capital letter A
"å" => "å", #latin small letter a
"Ã" => "Ã", #latin capital letter A
"ã" => "ã", #latin small letter a
"Ä" => "Ä", #latin capital letter A
"ä" => "ä", #latin small letter a
"Ç" => "Ç", #latin capital letter C
"ç" => "ç", #latin small letter c
"É" => "É", #latin capital letter E
"é" => "é", #latin small letter e
"Ê" => "Ê", #latin capital letter E
"ê" => "ê", #latin small letter e
"È" => "È", #latin capital letter E
/*... sorry cutting because limitation of php.net ...
... but the principle is it Wink ... */
"û" => "û", #latin small letter u
"Ù" => "Ù", #latin capital letter U
"ù" => "ù", #latin small letter u
"Ü" => "Ü", #latin capital letter U
"ü" => "ü", #latin small letter u
"Ý" => "Ý", #latin capital letter Y
"ý" => "ý", #latin small letter y
"ÿ" => "ÿ", #latin small letter y
"Ÿ" => "Ÿ", #latin capital letter Y
);

foreach ($html_entities as $key => $value) {
$str = str_replace($key, $value, $str);
}
return $str;
}
#4

[eluser]Riley123[/eluser]
ok found a good post here

http://php.net/manual/en/function.imap-8bit.php


comment this in email class;

//$subject = $this->_prep_q_encoding($subject);


use this instead. Also use the function i posted earlier to take care of the entities.

$subject = str_replace(" ", "_", trim($subject)) ;
// We need to delete "=\r\n" produced by imap_8bit() and replace '?'
$subject = str_replace("?", "=3F", str_replace("=\r\n", "", imap_8bit($subject))) ;
// Now we split by \r\n but with encoding text "=?ISO ..."
$subject = str_replace("\r\n", "?=\r\n =?ISO-8859-2?Q?", chunk_split($subject, 55)) ;
// We also have to remove last unneeded encoding text :
$subject = "=?ISO-8859-2?Q?" . substr($subject, 0, strlen($subject)-20) . "?=" ;




Theme © iAndrew 2016 - Forum software by © MyBB