When a legacy hook_mail() implementation sets $message['plain'] to a render Markup object (a rendered plain-text body, as easy_email does), the mailer_override legacy bridge throws a TypeError.
LegacyMailerHelper::emailFromArray() passes $message['plain'] straight to BaseEmail::setTextBody(), which is typed string:
TypeError: Drupal\symfony_mailer\BaseEmail::setTextBody(): Argument #1 ($body) must be of type string, Drupal\Core\Render\Markup given, called in LegacyMailerHelper.php on line 153.
The HTML body path already handles MarkupInterface in formatBody(); only the plain-text path is missing the conversion. Core PhpMail stringified the body implicitly, so legacy senders that supplied Markup worked before mailer_override.
Steps to reproduce:
1. Install symfony_mailer with the mailer_override submodule.
2. Send via the legacy mail manager with $message['plain'] set to Markup::create('some text').
3. The send fails with the TypeError above.
Proposed fix: cast to string at LegacyMailerHelper.php line 153, matching what core did implicitly:
$email->setTextBody((string) $message['plain']);
Happy to provide a merge request with a test.
Issue fork symfony_mailer-3594017
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mably commentedComment #4
adamps commentedThanks
Comment #5
adamps commented