Hi,

When mail are sent with the messaging system (my tests are made with html mails), the "from" (and Reply-To using the same variable) are malformed. When using gmail to see mails, no problems, but in Thunderbird accentued characters in [name] are replaced by some characters like é.

The format_from function in messaging.mail.inc must apply mime_header_encode function to name before returning informations to have correct values.

    $tokens = array(
-      '[name]' => $name,
+      '[name]' => mime_header_encode($name),
      '[mail]' => $mail,
    );

Mhm... And I think a better workaround will be to separate name and mail values in settings, to be sure to apply mime_header_encode to name, even if it's not a token...

For example, if I insert in the "messaging_mail_sender_format" the following string :

Un été en Inde [mail]

The string "Un été en Inde" will be malformed at display ("Un été en Inde"), because with my patch, I don't apply mime_header_encode on. Maybe a regex to retrieve the first part of the "from" and apply encoding can do the trick ?

Comments

titouille created an issue. See original summary.

titouille’s picture

Issue summary: View changes
titouille’s picture

Maybe better like this ? but It seems hard because maybe some users want to use specific name/email pattern to send their mail.

This pattern work nicely when pattern is "[name] <[email]>":

    $tokens = array(
      '[name]' => $name,
      '[mail]' => $mail,
    );
    $s = strtr(variable_get('messaging_mail_sender_format', '[name] <[mail]>'), $tokens);
    $matches = array();
    preg_match('/(?:"?([^"]*)"?\s)?(?:<?(.+@[^>]+)>?)/i', $s, $matches);
    list(, $_name, $_mail) = $matches;
    if (isset($_name) && isset($_mail)) {
      $_name = mime_header_encode($_name);
      $s = $_name . '<'.$mail.'>';
    }
    return $s;

But I think the best solution will be to separate name and email to apply mime_header_encode only to name before build the final "from" string...