function SymfonyMailer::mail
Same name in other branches
- 10 core/lib/Drupal/Core/Mail/Plugin/Mail/SymfonyMailer.php \Drupal\Core\Mail\Plugin\Mail\SymfonyMailer::mail()
Overrides MailInterface::mail
File
-
core/
lib/ Drupal/ Core/ Mail/ Plugin/ Mail/ SymfonyMailer.php, line 120
Class
- SymfonyMailer
- Defines an experimental mail backend, based on the Symfony mailer component.
Namespace
Drupal\Core\Mail\Plugin\MailCode
public function mail(array $message) {
try {
$email = new Email();
$headers = $email->getHeaders();
foreach ($message['headers'] as $name => $value) {
if (!in_array(strtolower($name), self::SKIP_HEADERS, TRUE)) {
if (in_array(strtolower($name), self::MAILBOX_LIST_HEADERS, TRUE)) {
// Split values by comma, but ignore commas encapsulated in double
// quotes.
$value = str_getcsv($value, ',');
}
$headers->addHeader($name, $value);
}
}
$email->to($message['to'])
->subject($message['subject'])
->text($message['body']);
$mailer = $this->getMailer();
$mailer->send($email);
return TRUE;
} catch (\Exception $e) {
Error::logException($this->logger, $e);
return FALSE;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.