Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect email encoding with CodeIgniter [closed]

Now the data looks like this in the database:

Hej [indtaster_navn]<br><br>I forbindelse med noget på ændring af xxxxxx er der behov for opfølgning på:<br><br>- xxxx<br>- xxxx<br>- xxxx<br><br>Jeg vil gerne have en tilbagemelding, når du har set på ovenstående.<br/><br/>Venlig hilsen<br/>[behandler_navn]<br/>TestGuy<br/><br/>[lokal_tlf] - lokal<br>00 00 00 00 - telefon<br>[behandler_email]<br><br>This S<br>Something<br>Transformer 1234<br>3434 BubbleJ<br><br>​​​​

So i have following code when sending a mail, where it's important to notice that i use html_entity_decode:

    $config['mailtype'] = 'html';
    $config['priority'] = 1;
    $config['charset'] = 'utf-8';
    $this->email->initialize($config);
    $this->email->from($this->auth_data->user_email, $this->auth_data->user_firstname . ' ' . $this->auth_data->user_lastname);
    $this->email->reply_to($this->auth_data->user_email, $this->auth_data->user_firstname . ' ' . $this->auth_data->user_lastname);
    $this->email->to('[email protected]'); 
    $this->email->subject($feedback_title_temp);
    $this->email->message(html_entity_decode($feedback_temp));  
    $this->email->send();

When i receive the email it inserts the symbol = random places and in some cases the <br> does not even occur.

For example:

- xxxx<=r>- xxxx

Should be:

- xxxx
- xxxx

When i view the email on my smartphone, the encoding problem only seems to occur with the æåø chars while Outlook is a completely different story.

Received email header::

**Microsoft Mail Internet Headers Version 2.0
Subject: =?utf-8?Q?(ID:_418)?=
To: [email protected]
X-PHP-Originating-Script: 0:Email.php
User-Agent: CodeIgniter
Date: Wed, 7 Nov 2012 00:31:54 +0100
From: <[email protected]>
Return-Path: <[email protected]>
Reply-To: "Johnny Bravo" <[email protected]>
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 1 (Highest)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_50999deab798e"
X-OriginalArrivalTime: 06 Nov 2012 23:31:54.0823 (UTC) FILETIME=[E8022570:01CDBC76]

--B_ALT_50999deab798e
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

--B_ALT_50999deab798e
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable


--B_ALT_50999deab798e--
**

Received mail, based on different content, but the errors are very obvious:

Det her er en m=sse tekst, det er bare en test fra en hæææst.


- Hehe
- Heh<=br>
- Wee


A=l these things

- Lots of text
like image 729
JavaCake Avatar asked Oct 27 '25 07:10

JavaCake


1 Answers

$this->email->set_crlf( "\r\n" );

Fixed the problem!

like image 123
JavaCake Avatar answered Oct 29 '25 21:10

JavaCake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!