public static function Email::sendMessages in Courier 8
Same name and namespace in other branches
- 2.x src/Entity/Email.php \Drupal\courier\Entity\Email::sendMessages()
Parameters
array $options: Miscellaneous options.
- reply_to: reply-to email address, or leave unset to use site default.
Overrides ChannelInterface::sendMessages
1 call to Email::sendMessages()
- Email::sendMessage in src/
Entity/ Email.php - Sends this message.
File
- src/
Entity/ Email.php, line 146 - Contains \Drupal\courier\Entity\Email.
Class
- Defines storage for a composed email.
Namespace
Drupal\courier\EntityCode
public static function sendMessages(array $messages, $options = []) {
/* @var \Drupal\courier\EmailInterface[] $messages */
foreach ($messages as $message) {
if (!($email = $message
->getEmailAddress())) {
throw new ChannelFailure('Missing email address for email.');
}
$name = $message
->getRecipientName();
$email_to = !empty($name) ? "{$name} <{$email}>" : $email;
$params = [
'context' => [
'subject' => $message
->getSubject(),
'message' => $message
->getBody(),
],
];
/** @var \Drupal\Core\Mail\MailManagerInterface $mailman */
$mailman = \Drupal::service('plugin.manager.mail');
$mailman
->mail('system', 'courier_email', $email_to, $message
->language()
->getId(), $params, array_key_exists('reply_to', $options) ? $options['reply_to'] : NULL);
}
}