protected function SwiftMailer::getContentType in Swift Mailer 8.2
Returns the message content type.
@internal
Parameters
array $message: The message for which the applicable format is to be determined.
Return value
string A string being the applicable format.
2 calls to SwiftMailer::getContentType()
- SwiftMailer::format in src/
Plugin/ Mail/ SwiftMailer.php - Formats a message composed by drupal_mail().
- SwiftMailer::mail in src/
Plugin/ Mail/ SwiftMailer.php - Sends a message composed by drupal_mail().
File
- src/
Plugin/ Mail/ SwiftMailer.php, line 486
Class
- SwiftMailer
- Provides a 'Swift Mailer' plugin to send emails.
Namespace
Drupal\swiftmailer\Plugin\MailCode
protected function getContentType(array $message) {
// The message parameter takes priority over config. Support the alternate
// parameter 'format' for back-compatibility.
$content_type = $message['params']['content_type'] ?? $message['params']['format'] ?? $this->config['message']['content_type'];
// 1) check the message parameters.
if ($content_type) {
return $content_type;
}
// Then check the Content-Type header.
if (isset($message['headers']['Content-Type'])) {
return explode(';', $message['headers']['Content-Type'])[0];
}
// Drupal sets the header by default, but add a fallback just in case.
return 'text/plain';
}