Author Topic: Problem charset sender name  (Read 5738 times)

Offline filip

  • Newbie
  • *
  • Posts: 3
Problem charset sender name
« on: December 27, 2006, 06:42:59 PM »
Hello,

When I am sending an e-mail from roundcube to a gmail adress for example, if my name is : Malée, it will display it in gmail as : =?UTF-8?Q?Mal=C3=A9e
It it is not very pleasant for people who are receving my emails.

Other wise, all the other accents of the subject and of the text are well displayed.

Thank you for your help.


Offline eymerich

  • Newbie
  • *
  • Posts: 5
Re: Problem charset sender name
« Reply #1 on: January 01, 2007, 06:32:41 AM »
Hi,
I have the same problem so I have got a look in the code, appears to me that the function who encodes 'From' field execute his operations on whole string composed by
Code: [Select]
nickname <mail@domain.ext> so it puts in the header the result
Code: [Select]
From: =?UTF-whatever...blabla_=?, in this case when header is passed to the PEAR function who is entitled to process data and send it to server you have as result that someone (PEAR or SMPT I don't know) add the domain extension to this field resulting in a field of the type
Code: [Select]
=?UTF-whatever...blabla_?=@domain.ext in this case this is not a well formatted 'From' field and we can see the results of this in our recipents mail client, a correct 'From' field is kind
Code: [Select]
From: =?UFT-whatever..blabla?= , I have modified the txtHeaders function in lib/Mail/mime.php to take care of these considerations, it takes 'From' field from array with only the nickname who eventually should be encoded, than, after add your mail address with a straight copy, it seems to work but I don't know if the encoding of whole 'From' field is necessary (mail address with specialchars perhaps?)

My configuration is SMTP Postfix, PHP 4.4.4.

Offline filip

  • Newbie
  • *
  • Posts: 3
Re: Problem charset sender name
« Reply #2 on: January 01, 2007, 11:59:45 AM »
Hi,

Thanks for your reply.
Could you show me exactly what you have modified in your txtHeader function ? Because I don't understand very well what you did.

Offline eymerich

  • Newbie
  • *
  • Posts: 5
Re: Problem charset sender name
« Reply #3 on: January 01, 2007, 02:45:02 PM »
Hi, those are my modifications :) I can't guarantee they don't put on flames your server :P
Code: [Select]
diff -urNp old/program/lib/Mail/mime.php new/program/lib/Mail/mime.php
--- old/program/lib/Mail/mime.php 2007-01-01 12:58:26.000000000 +0100
+++ new/program/lib/Mail/mime.php 2007-01-01 12:58:02.000000000 +0100
@@ -695,12 +695,17 @@ class Mail_mime
   * @return string Plain text headers
   * @access public
   */
-  function txtHeaders($xtra_headers = null, $overwrite = false)
+  function txtHeaders($xtra_headers = null, $overwrite = false, $sender_address = null)
   {
     $headers = $this->headers($xtra_headers, $overwrite);
     $ret = '';
     foreach ($headers as $key => $val) {
-      $ret .= &quot;$key: $val&quot; . MAIL_MIME_CRLF;
+ if($key == &quot;From&quot;)
+ {
+ if($sender_address != null) $ret .= &quot;$key: $val <$sender_address>&quot; . MAIL_MIME_CRLF;
+ else $ret .= &quot;$key: $val&quot;. MAIL_MIME_CRLF;
+ }
+     else $ret .= &quot;$key: $val&quot; . MAIL_MIME_CRLF;
     }
     return $ret;
   }
diff -urNp old/program/steps/mail/sendmail.inc new/program/steps/mail/sendmail.inc
--- old/program/steps/mail/sendmail.inc 2007-01-01 12:57:27.000000000 +0100
+++ new/program/steps/mail/sendmail.inc 2007-01-01 12:57:46.000000000 +0100
@@ -108,7 +108,7 @@ if (empty($identity_arr['string']))
 
 // compose headers array
 $headers = array('Date' => date('D, j M Y G:i:s O'),
-         'From' => $identity_arr['string'],
+         'From' => $identity_arr['name'],
         'To'  => rcube_charset_convert($mailto, $input_charset, $message_charset));
 
 // additional recipients
@@ -240,7 +240,7 @@ if (!$savedraft) {
   unset($send_headers['Bcc']);
 
   // generate message headers
-  $header_str = $MAIL_MIME->txtHeaders($send_headers);
+  $header_str = $MAIL_MIME->txtHeaders($send_headers, false, $identity_arr['email']);
 
   // send message
   $sent = smtp_mail($from, $a_recipients, $header_str, $msg_body);

Offline filip

  • Newbie
  • *
  • Posts: 3
Re: Problem charset sender name
« Reply #4 on: January 01, 2007, 04:57:00 PM »
Thank you very much !
 :)
It is working well now.

Offline zorensen

  • Newbie
  • *
  • Posts: 9
Re: Problem charset sender name
« Reply #5 on: January 09, 2007, 04:41:19 AM »
Hi everyone!

I tried to do this, but then RoundCube would'nt send any e-mails.
It just said "Sendng e-mail" and nothing happened. Maybe I did it the wrong way..:

Can anyone tell me detailed how to fix this? Sorry, but I'm a bit of a newbie :-)
I got the latest version of RoundCube.

Offline eymerich

  • Newbie
  • *
  • Posts: 5
Re: Problem charset sender name
« Reply #6 on: January 09, 2007, 07:09:01 AM »
Latest from site or latest from SVN?

Offline zorensen

  • Newbie
  • *
  • Posts: 9
Re: Problem charset sender name
« Reply #7 on: January 09, 2007, 12:18:18 PM »
Latest from site.

What is the difference between SVN and the one from the site?? :)

Please help me solve this problem! :-)

Offline eymerich

  • Newbie
  • *
  • Posts: 5
Re: Problem charset sender name
« Reply #8 on: January 09, 2007, 08:24:28 PM »
Latest SVN is a snapshoot of the version under development, files are different from the milestone release; my mod is based on the 0.1 beta 2 released near xmas so you should have the correct version to apply the mods.

You can apply the patch by hand looking at code generated by diff program (posted above), otherwise you can use the diff counterpart ,patch, which will apply the patch for you following instructions in patch files who you can find in the attached archive.

If you have Windows use the patch file with (w32) string in the name (check attached archive), install patch.exe program by downloading this package http://gnuwin32.sourceforge.net/downlinks/patch.php, unzip roundcube sources in a folder, copy patch in this folder, go in console/prompt ad enter this folder, than, run a test to see if patch will apply
Code: [Select]
C:\Program\GnuWin32\bin\patch -p1 --dry-run < file_bla_bla_bla.patch
...if you read...
Code: [Select]
patching file program/lib/Mail/mime.php
patching file program/steps/mail/sendmail.inc

... all may run smooth so patch with the command:
Code: [Select]
C:\Program\GnuWin32\bin\patch -p1 < file_bla_bla_bla.patch
you should have now the patched and working files in their respective folders.

Hope this will help.


Offline Ateo

  • Newbie
  • *
  • Posts: 4
Re: Problem charset sender name
« Reply #9 on: February 04, 2007, 05:26:14 AM »
Patch worked fine for accented characters in the "From" header.

Very cool mail client.. =)