Problem/Motivation
As per the documentation - https://api.drupal.org/api/drupal/core!core.api.php/function/hook_mail_a... - the 'body' key of the $message attribute should be an array of strings. In the InviteByEmail plugin it is a single string.
As a result, @Mail plugins that are being type strict will fail to process invitation emails.
Steps to reproduce
Send an invitation by email with a mail plugin that requires the $message['body'] to be an array (as per the documentation)
Proposed resolution
Make it an array with a single item:
$message['body'][] = \Drupal::service('renderer')->render($body)->__toString();
Instead of:
$message['body'] = \Drupal::service('renderer')->render($body)->__toString();
Comments
Comment #3
kalpaitch commentedComment #4
renatog commentedWe're planning to release the new version 2.0.x so let's move this for the new version
Comment #5
renatog commentedHey @kalpaitch, thanks for you fix. I've try to apply that on 2.0.x, so follow the new patch
Comment #6
renatog commentedI was trying but is returning this error:
Do you have some idea about what can be?
Comment #7
dale42I believe this issue would be resolved by using the code in #3275572: Implement hook_mail().
I can create a patch for the 2.0.x branch, if you like.
Comment #8
renatog commentedAh amazing @dale42.
Yeaaah, If you can, please
I can commit that for us o/
Comment #9
dale42Attached is patch file invite-hook-mail-upd-3227581-9.patch with the changes from #3275572.
I tested with the native Drupal mailer and Swift mailer.
Comment #10
renatog commentedI applied and tested. It really works well
Thanks a lot for your contribution @dale42 and @kalpaitch
Comment #12
renatog commentedCommitted to the dev branch.
Thanks a lot