In edge cases, reroute mail returns an array when code expects a string
| Project: | Reroute Email |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
| Issue tags: | Science Collaboration |
(This isn't necessarily reroute_email's bug to fix, but it's easy to fix in reroute_email.)
At least one module, Messaging, invokes hook_mail_alter itself, bypassing drupal_mail_send.
After reroute_email does its alter, notifications calls drupal_mail directly and this error results:
"warning: mail() expects parameter 3 to be string, array given in /var/www/example/drupal/includes/mail.inc on line 193."
As Stefan of Agaric wrote in IRC while debugging this: It is not wrong to have an array as mail body because if the function drupal_mail is used for sending it it will be imploded. However, messaging_mail bypasses drupal_mail and uses drupal_mail_send directly which does not do that. (It calls the hook_mail_alter but does not convert the body if necessary, whereas drupal_mail converts the array and calls all the hooks. drupal_mail_send is like a private function not intended as api part, probably there's a reason but it bypasses some important logic.)

#1
This attached patch makes sure that reroute_email returns a message body in the same type (array or string) as was handed to it.
#2
Hmmm.
The patch is empty.