HTML MAIL feature is not working correctly. Some of the users are not receiving email. It is important as these are the account confirmation emails.

Error Message : "The mailsystem_html_to_text() function did not return any text. Please report this error to the Mail system issue queue."

I am trying to send a HTML email. The message body has some HTML Code. I am getting the above error and email is not sent to the user.

// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);

// Format the message body.
$message = $system->format($message);

// Send e-mail.
$message['result'] = $system->mail($message);

Members fund testing for the Drupal project. Drupal Association Learn more


mshettar’s picture

Priority: Normal » Major

Updating priority.

pillarsdotnet’s picture

Please do this:

  1. Apply the attached patch to your Mailystem module directory.
  2. Trigger the sending of an account confirmation email.
  3. Check your /admin/reports/dblog page for a message with type = mailsystem.
  4. When found, attach the message to this issue.

Thank you.

pillarsdotnet’s picture

Assigned: Unassigned » pillarsdotnet
Status: Active » Postponed (maintainer needs more info)
lilott8’s picture

Title: Users not receiving email » mailsystem_html_to_text() function did not return any text
Status: Postponed (maintainer needs more info) » Active

I've just added the patch and will await the next email to go out. When that happens I will upload the message for you.

I am using php 5.4. Also your patch doesn't function. I had to tweak it to read:

$text_temp = trim($text);
$string_temp = trim($string);

if (empty($text_temp) && !empty($string_temp)) {
  //throw watchdog error.

I was getting a cannot use return value as write context errors.

for search purposes:
mailsystem_html_to_text() function did not return any text
lilott8’s picture

Here are some logs:

Feb 27 08:38:55 [obscured] drupal: [obscured]|1361975935|mailsystem||[obscured]/directory/profile/[obscured]|[obscured]/directory/profile/[obscured]|0||purplemonkeys Converting "#012#012" to text yields an empty string.

Feb 27 08:38:55 www01 drupal: [obscured]|1361975935|htmlmail||[obscured]/directory/profile/[obscured]|[obscured]/directory/profile/[obscured]|0||The mailsystem_html_to_text() function did not return any text. Please report this error to the Mail system issue queue.

This is what was sent:

Feb 27 08:38:55 www01 drupal: [obscured]|1361975935|directory||[obscured]/directory/profile/[obscured]|[obscured]/directory/profile/[obscured]|0||Directory webform sent [obscured]: [obscured] [obscured] : Hedirectory_webformi_Files @ [obscured] Saying: #012Hi [obscured] #012#012[obscured] is dressing up be like you [obscured] day, and she has a small pillow under her shirt mimick your baby bump. We hope that this is okay. She really wants look like you day, and she doesn't mean any disrespect. We hope that's okay. I imagine she will take out the pillow early on in the morning.#012#012Have a wonderful day!#012#012Hedirectory_webformi Files#012Sender's IP: [obscured]

note: I put the purplemonkeys in there for easy search.

lilott8’s picture

Is this dead? Because people are getting empty emails from us! Please, we've tried just about everything. I've even modified some of the code to try and avert this...

SKAUGHT’s picture

'it seems' that you need mail_system variable to be setup as (use /admin/config/system/mailsystem to setup).

  • the site-wide default is DefaultMailSystem
  • the YOUR-MODULE was created from the 'new setting' field set.
    1. module: YOUR-MODULE
    2. key: YOUR-KEY
  • The htmlmail was created in the "new class' field set. With both 'format' and 'mail' set to 'HTMLMailSystem'

a Variable dump of mail_system:

    [default-system] => DefaultMailSystem
    [htmlmail] => HTMLMailSystem

then drupal_mail works (yes, 'htmlmail' even though you expect to use YOUR-MODULE):

if (drupal_mail('htmlmail', 'YOUR-KEY', $client_to, language_default(), $client_params, '', TRUE)) {
 //if mail is sent..
} else {
 //if mail not sent..


follow up: my third list point seems not to set it.. sending a test [ /admin/config/system/htmlmail/test ] seems to set var for mail_system([htmlmail] => HTMLMailSystem )

themed mail tpl to use:

lilott8’s picture

268.97 KB

You can see my setup for the mailsystem. It's been working really well for at least a year. It just started randomly sending blanks to people. I have the following installed:

  • php 5.4.11
  • Pear Mail_Mime 1.8.7
  • Pear Mail_mimeDecode 1.5.5
  • D7
  • Mail Mime 7-2.17
  • MailSystem 7-2.34
  • HTMLMail 7-2.65

As far as I can tell, it is installed and configured according to the readme.txt file.


dgtlmoon’s picture

this can be caused by something using drupal_mail incorrectly.

pwsherman’s picture

Issue summary: View changes

I'm also getting this message in my HTMLMail system logs, but mails seem to be going out.

supriyarajgopal’s picture

Subscribing..I am facing the same issue!

sodu.parsiev’s picture

this error happens at this place

To prevent this error you should in hook_mail set message body.