[development] Email content type UTF8 not accepted

Diego G diegomartinsbh at hotmail.com
Mon Aug 16 09:40:28 UTC 2010

Hello everyone

I have a module that sends text/html emails using the function drupal_mail().
Everything was working fine until I needed to send them in German, instead of English.

I changed the email's content type header to "text/html; charset=utf-8", but the email is always sent as "text/html; charset=iso-8859-1", and the German characters are not properly shown.

I tried to send it to several different mail servers (yahoo, hotmail, and others), and the result was the same.
Intriguingly, when I change the content type to "text/plain; charset=utf-8", the charset is kept UTF-8, as I want, and the characters are properly shown. This problem only happens when the content type is "text/html".

I also tried to set the content type header within the html code to "text/plain; charset=utf-8" too, but the problem persisted.

It seems like Drupal is changing the charset to iso-8859-1.

Does anyone have any idea of what is causing this problem?



This is my code:


$language = user_preferred_language();

$params = array(
  'subject' => t('Test'),
  'body' => t($message, $variables, $language->language)

drupal_mail('notification', 'notice', $email, $language, $params);


function notification_mail($key, &$message, $params) {

  $message['headers']['Content-Type'] = "text/html; charset=utf-8";
  $message['subject'] = $params['subject'];
  $message['body'][] = $params['body'];

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100816/c6e27741/attachment.html 

More information about the development mailing list