Login   Register  
PHP Classes
elePHPant
Icontem

UTF-8 encoding

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Nomad MIME Mail  >  All threads  >  UTF-8 encoding  >  (Un) Subscribe thread alerts  
Subject:UTF-8 encoding
Summary:Strange UTF-8 behavour between different mail clients
Messages:2
Author:Ulf Bergum
Date:2009-04-21 12:48:08
Update:2009-04-22 02:54:43
 

  1. UTF-8 encoding   Reply   Report abuse  
Picture of Ulf Bergum
Ulf Bergum
2009-04-21 12:48:08
I have expreienced some difficulties regarding UTF-8 encoded text in the subject header. In some clients the encoding is ok, but in others there are obvious something wrong. This occures when sending a mail using a web-form. When I hardcode the text for the subject in the script it works just well. I have also checked the encoding passed by the form with mb_detect_encoding(), and it reports UTF-8. The body seems ok though.

The following headers are sendt simultaneously to the 2 adresses from the same form.

Any suggestions?



Gmail example (OK):

To: myadress@gmail.com
Subject: test
X-PHP-Script: mydomain.com/admin/medlemskap/massemail/new.php
From: Namsos Turnforening <webmaster@mydomain.com>
Reply-To: Namsos Turnforening <webmaster@mydomain.com>
Content-Type: multipart/alternative; boundary="=-nxs_alt_23799b75f3ab836822308092319393ff"
MIME-Version: 1.0
X-Mailer: Nomad MIME Mail 1.6.2
Date: Tue, 21 Apr 2009 13:51:36 +0200

--=-nxs_alt_23799b75f3ab836822308092319393ff
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit



--=-nxs_alt_23799b75f3ab836822308092319393ff
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: 7bit


--=-nxs_alt_23799b75f3ab836822308092319393ff--


Other server with RoundCube client (Error):

To: myadress@anotherserver.com
Subject: test ÆØÅ æøå
X-PHP-Script: mydomain.com/admin/medlemskap/massemail/new.php
From: Namsos Turnforening <webmaster@mydomain.com>
Reply-To: Namsos Turnforening <webmaster@mydomain.com>
Content-Type: multipart/alternative; boundary="=-nxs_alt_3f633ebf5a2cea8504d8d01f3066e07b"
Message-Id: <5fd88a8ed6f88e200f67feabda37fd5f
MIME-Version: 1.0
X-Mailer: Nomad MIME Mail 1.6.2
Date: Tue, 21 Apr 2009 13:55:31 +0200

--=-nxs_alt_3f633ebf5a2cea8504d8d01f3066e07b
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

æøå

--=-nxs_alt_3f633ebf5a2cea8504d8d01f3066e07b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: 7bit

æøå
--=-nxs_alt_3f633ebf5a2cea8504d8d01f3066e07b--




  2. Re: UTF-8 encoding   Reply   Report abuse  
Picture of Alejandro Garca Gonzlez
Alejandro Garca Gonzlez
2009-04-22 02:54:43 - In reply to message 1 from Ulf Bergum
Try Changing this functions:


function set_subject($subject)
{
$this->mail_subject = !empty($subject) ? mb_convert_encoding(trim($subject), $this->charset) : "No subject";
}


function set_text($text)
{
if (!empty($text)){
$this->mail_text = preg_replace("(\r\n|\r|\n)", BR, mb_convert_encoding($text, $this->charset)) ;
}
}

function set_html($html)
{
if (!empty($html)){
$this->mail_html = preg_replace("(\r\n|\r|\n)", BR, mb_convert_encoding($html), $this->charset));
}
}

Please, tell me if works.

Bye