Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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'));
...
Comment | File | Size | Author |
---|---|---|---|
#3 | hook_mail_alter_ex1.patch | 792 bytes | dale42 |
Comments
Comment #1
jhodgdonThis is also an issue in the Drupal 7 doc. Please patch there first, then back-port to Drupal 6.
Comment #2
dale42I'm currently working on #519498: Document that $params is available to hook_mail_alter(). Will do this ticket, too.
Comment #3
dale42Comment #4
jhodgdonLooks good to me.
Comment #5
webchickOh 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.
Comment #6
jhodgdonThis is in the contrib repository for Drupal 6, so I went ahead and committed the change. http://drupal.org/cvs?commit=269618