// Invoke hook_mail_alter() to allow all modules to alter the resulting
// email.
$this->moduleHandler->
alter('mail',
$message);
// Retrieve the responsible implementation for this message.
$system =
$this->
getInstance(['module' =>
$module, 'key' =>
$key]);
// Attempt to convert relative URLs to absolute.
foreach ($message['body'
] as &
$body_part) { if ($body_part instanceof MarkupInterface
) { $body_part = Markup::
create(Html::
transformRootRelativeUrlsToAbsolute((string) $body_part, \Drupal::
request()->
getSchemeAndHttpHost()));
} } // Format the message body.
$message =
$system->
format($message);
// Optionally send email.
if ($send) { // The original caller requested sending. Sending was canceled by one or
// more hook_mail_alter() implementations. We set 'result' to NULL,
// because FALSE indicates an error in sending.