See this documentation page: http://api.drupal.org/api/function/hook_mail_alter/6

The Parameters section says that $message['body'] will be an array of lines. However, in the sample code at the bottom of the page, it is treated as a string:

...
$message['body'] .= "\n\n--\nMail sent out from " . variable_get('sitename', t('Drupal'));
...

If you were to use this code, $message['body'] would normally end up containing the string "Array\n\n--\nMail send out from My Site".

The correct code should instead be something like:

...
$message['body'][] = '';
$message['body'][] = '--';
$message['body'][] = 'Mail sent out from ' . variable_get('sitename', t('Drupal'));
...
CommentFileSizeAuthor
#3 hook_mail_alter_ex1.patch792 bytesdale42
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Version: 6.13 » 7.x-dev

This is also an issue in the Drupal 7 doc. Please patch there first, then back-port to Drupal 6.

dale42’s picture

Assigned: Unassigned » dale42

I'm currently working on #519498: Document that $params is available to hook_mail_alter(). Will do this ticket, too.

dale42’s picture

Status: Active » Needs review
FileSize
792 bytes
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

webchick’s picture

Version: 7.x-dev » 6.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Oh dear heaven, thank you for fixing 1/1000th of the WTFs in the mail API documentation. :)

Moving down to 6.x, as I think this needs to be fixed there too.

jhodgdon’s picture

Status: Patch (to be ported) » Fixed

This is in the contrib repository for Drupal 6, so I went ahead and committed the change. http://drupal.org/cvs?commit=269618

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.