Welcome Guest, Not a member yet? Register   Sign In
Email library and HTML content with accented characters
#1

[eluser]doMynation[/eluser]
Hello,

This is my code representing two ways of sending HTML content via e-mail.
Both ways work fine except that in the way #2, the accented characters aren't displayed.

I've tried to change the caracters encoding of the view file using Notepad++, without success.

My guess is that the Loader's view() function neglects accented characters or something.

Code:
// Way #1 (works with accented characters)
$body = '
<a href="'.site_url('service/serviceRequest').'">Service à la clientèle...</a>
<div style="background-color:#CCCCCC">Accènt aigüe éllo test</div>';

// Way #2 (accented characters aren't displayed)
$data['firstName'] = 'Dominique';
$data['lastName'] = 'Sarrazin';
$body = $this->load->view('pavilion/email', $data, true); // loading the email body

$this->email->charset = 'iso-8859-1'; // setting the charset to latin-1 (allowing accented characters)
$this->email->mailtype = 'html';            
$this->email->to($cusEmail);
$this->email->from(EMAIL_NOREPLY, SERVICE_NAME_FROM);
$this->email->subject('Enregistrement de produit - Confirmation');
$this->email->message($body); // sending the HTML body    
        
return $this->email->send();

Does anyone have the same problem ?

Thank you !
#2

[eluser]TheFuzzy0ne[/eluser]
Was there something wrong with the default value (UTF-8)?
#3

[eluser]doMynation[/eluser]
Indeed, UTF-8 didn't work with accented characters.
#4

[eluser]TheFuzzy0ne[/eluser]
Hmm... That's strange. What do the Email headers say in the 'Content-Type' field(s)?
#5

[eluser]doMynation[/eluser]
In the header:

(When I set the charset to iso-8859-1)
Content-Type: text/plain; charset=iso-8859-1

(When I set the charset to UTF-8)
Content-Type: text/plain; charset=utf-8
#6

[eluser]doMynation[/eluser]
I've just tested it in outlook and it seems like the preview mode (the little rectangle popup that appears when you receive an e-mail) works with the accented characters. However when I click on it to display the full email in Outlook, now the accented characters are stripped.


This is wierd..
#7

[eluser]TheFuzzy0ne[/eluser]
It is. This could be an issue with Outlook, but I doubt it, unless your PC is suffering from a mild case of bit-rot. I was going to suggest you check that your HTML is valid, but since you're using plain/text encoding, it's obvious you're not using HTML. Can you test it with another Email client and perhaps a few of the well known Web clients, such as Hotmail, err... Windows Live(?), GMail, Yahoo and the likes?
#8

[eluser]doMynation[/eluser]
Works when I send it to a gmail in both UTF-8 and latin-1

So the problem is obviously in Outlook. There must be a setting which converts any incoming e-mail to a specific charset.
#9

[eluser]TheFuzzy0ne[/eluser]
In a situation like yours, I'd start spamming any of my mates that use outlook express and asking them if they have the same issue.




Theme © iAndrew 2016 - Forum software by © MyBB