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