WebformPhpMail.php in Webform 6.x
File
src/Plugin/Mail/WebformPhpMail.php
View source
<?php
namespace Drupal\webform\Plugin\Mail;
use Drupal\Core\Mail\Plugin\Mail\PhpMail;
use Drupal\Core\Mail\MailFormatHelper;
class WebformPhpMail extends PhpMail {
public function format(array $message) {
$message['body'] = implode("\n\n", $message['body']);
if (!empty($message['params']['html'])) {
if (strpos($message['body'], '<html') === FALSE) {
$message['params'] += [
'webform_submission' => NULL,
'handler' => NULL,
];
$build = [
'#theme' => 'webform_email_html',
'#body' => $message['body'],
'#subject' => $message['subject'],
'#webform_submission' => $message['params']['webform_submission'],
'#handler' => $message['params']['handler'],
];
$message['body'] = \Drupal::service('renderer')
->renderPlain($build);
}
return $message;
}
else {
$message['body'] = MailFormatHelper::wrapMail($message['body']);
return $message;
}
}
}
Classes
Name |
Description |
WebformPhpMail |
Extend's the default Drupal mail backend to support HTML email. |