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?
Cheers
Diego
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'];
}