Format mail body as string

Created on 10 August 2021, over 3 years ago
Updated 23 July 2023, over 1 year ago

Problem/Motivation

Currently looking at the mail plugin GovUKNotifyMail::mail() it expects the $message['body'] to be an array, however, it does seem that the MailInterface::mail() expects it to be an already formatted string.

It expects that the message body has already been formatted to a string by the time it reaches the plugin's mail() method. It appears that we are not handling this as expected in the format() method.

Steps to reproduce

Instantiate a mail plugin but send the message later:

$message = \Drupal::service('plugin.manager.mail')->mail('example', 'notice', $to, $langcode, $params, FALSE);
$message['body'] = "An externally formatted mail body."
$system = \Drupal::service('plugin.manager.mail')->getInstance([
    'module' => 'example',
    'key' => 'notice',
]);
$system->mail($message);

Proposed resolution

  • Add formatting for the mail body to wrap into a string.
  • Remove array functions on $message['body'] in mail().
πŸ“Œ Task
Status

Needs work

Version

2.1

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom kalpaitch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024