I am using drupal_mail() function to send email. I have PHPMailer module with Mime Mail. It works perfectly, embedding images, sending HTML code, but for some reason, the subject line is pledged with bad characters, all the special chars of other languages do not display, a 'X' character display instead, but in the body of the message, it appears perfectly.

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

        'MIME-Version' => '1.0',
        'Content-Type' => 'text/html; charset=UTF-8; ',
        'Content-Transfer-Encoding' => '8bit',
        'Return-Path' => $params["from"],
        'Reply-To' => $params["from"],
  • 1
    I'm voting to close this question as off-topic because it's a bugreport for PHPMailer or Mime Mail, and should rather be reported in their issue queues.
    – Mołot
    Jan 22, 2015 at 8:27
  • How can I check it? Switching off modules PHPMailer and MimeMail and sending?
    – Cesar
    Jan 22, 2015 at 8:29
  • That would probably only kick you into all the unpleasant things that makes many of us abandon Drupal default way - PHP mail() function.
    – Mołot
    Jan 22, 2015 at 8:34
  • Well, I am stuck. I cannot send email directly because of server configuration. With library of phpMailer it works perfect, but just sending via PHP. So I abandon PHPMailer module, MimeMail module, mymodule_mail and fall into the open arms of just plain PHP with phpMailer class. Incredible.
    – Cesar
    Jan 22, 2015 at 9:01
  • Why don't you try posting a bugreport? If somehow it is not a bug, maintainers will know and will notify you about what you are doing wrong. And if it is a bug, they can fix it.
    – Mołot
    Jan 22, 2015 at 9:03

1 Answer 1


There are no bugs. Maybe lazy code from the developers.

Just simply put this line

mb_encode_mimeheader($params["subject"],"UTF-8", "B", "\n");

for the subject and works in all languages and codifications (chinese, etc.). It is tremendous that phpMailer class in itself handles perfectly, but when you use the phpMailer module, this encapsulating dissapears and you have to hard-code in the mymodule_mail() function.

Sincerely, Drupal is not suited for big projects.

  • Thank you !! for me works using: mb_encode_mimeheader(utf8_decode($message['subject']),"UTF-8", "B", "\n");
    – ropic
    Jul 17, 2017 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.