public function EasyEmailController::preview in Easy Email 8
Same name and namespace in other branches
- 2.0.x src/Controller/EasyEmailController.php \Drupal\easy_email\Controller\EasyEmailController::preview()
1 call to EasyEmailController::preview()
- EasyEmailController::previewType in src/
Controller/ EasyEmailController.php
File
- src/
Controller/ EasyEmailController.php, line 114
Class
- EasyEmailController
- Class EasyEmailController.
Namespace
Drupal\easy_email\ControllerCode
public function preview(EasyEmailInterface $easy_email) {
$message = \Drupal::service('easy_email.handler')
->preview($easy_email);
$body = trim($message['body']);
// If email is plain text, HTML body is empty.
if (!empty($message['headers']['Content-Type']) && strstr($message['headers']['Content-Type'], 'text/plain')) {
$body = '';
}
$response = new Response();
$response
->setContent($body);
$response->headers
->set('Content-Type', 'text/html; charset=utf-8');
return $response;
}