function MailInterface::format
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Mail/MailInterface.php \Drupal\Core\Mail\MailInterface::format()
- 10 core/lib/Drupal/Core/Mail/MailInterface.php \Drupal\Core\Mail\MailInterface::format()
- 11.x core/lib/Drupal/Core/Mail/MailInterface.php \Drupal\Core\Mail\MailInterface::format()
Formats a message prior to sending.
Allows to preprocess, format, and postprocess a mail message before it is passed to the sending system. The message body is received as an array of lines that are either strings or objects implementing \Drupal\Component\Render\MarkupInterface. It must be converted to the format expected by mail() which is a single string that can be either plain text or HTML. In the HTML case an alternate plain-text version can be returned in $message['plain'].
The conversion process consists of the following steps:
- If the output is HTML then convert any input line that is a string using \Drupal\Component\Utility\Html\Html::Escape().
- If the output is plain text then convert any input line that is markup using \Drupal\Core\Mail\MailFormatHelper::htmlToText().
- Join the input lines into a single string.
- Wrap long lines using \Drupal\Core\Mail\MailFormatHelper::wrapMail().
Parameters
array $message: A message array, as described in hook_mail_alter().
Return value
array The formatted $message.
See also
\Drupal\Core\Mail\MailManagerInterface
1 method overrides MailInterface::format()
- PhpMail::format in core/
lib/ Drupal/ Core/ Mail/ Plugin/ Mail/ PhpMail.php - Concatenates and wraps the email body for plain-text mails.
File
-
core/
lib/ Drupal/ Core/ Mail/ MailInterface.php, line 41
Class
- MailInterface
- Defines an interface for pluggable mail back-ends.
Namespace
Drupal\Core\MailCode
public function format(array $message);
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.