Hello,

Using non-ascii caracters in the "From:" field should be encoded (with mime_header_encode?) in order to be read correctly by non-UTF8 readers and to not get stopped by spam-filters.

For example: "From: Étienne Foo" needs to be "From: =utf8?...tienne Foo".
Same problem with cyrillic or other alphabets.

I have made the following changes to mimemail.module in order to solve the problem. Can you confirm if it is correct?

function mimemail_address($address) {
    
  if (is_array($address)) {
               
    // it's an array containing 'mail' and/or 'name'
    if (isset($address['mail'])) {
      $output = '';
      if (empty($address['name'])) {
        return $address['mail'];
      } else { 
        return '"'.addslashes(mime_header_encode($address['name'])).'" <'.$address['mail'].'>'; // [ML]
      }
    } 
        
    // it's an array of address items
    $addresses = array();
    foreach($address as $a) {
      $addresses[] = mimemail_address($a);
    }
    return $addresses;
  }
  
  // it's a user object
  if (is_object($address) && isset($address->mail)) {
    return '"'.addslashes(mime_header_encode($address->name)).'" <'.$address->mail.'>'; // [ML]
  } 
  
  // it's formatted or unformatted string
  // TODO shouldn't assume it's valid - should try to re-parse
  if (is_string($address)) {
    return $address;
  }

  // it's null.  return the site default address
  if (is_null($address)) {
    return array(
      'name' => mime_header_encode(variable_get('site_name', 'Drupal')), // [ML]
      'mail' => variable_get('site_mail', ini_get('sendmail_from')),
    );
  }

  return false;
}

Patch included in attachment. (the patch is made on the HEAD, but I am using 1.x)

Thanks,

Mathieu Lutfy
Réseau Koumbit

CommentFileSizeAuthor
mimemail.module.patch1.36 KBbgm

Comments

jerdavis’s picture

Assigned: Unassigned » jerdavis

I'll test this and report back, looks good though.

jerdavis’s picture

Status: Needs review » Fixed

Commited this to HEAD with the inclusion of a mime_header_encode() call within mimemail_headers().

Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.