public function send()
{
if (null === $this->message->getMessage()) {
$this->message->init();
}
$messageBody = $this->message->getMessage();
$headers = $this->buildHeaders() . $this->message->getEol() . $this->message->getEol();
// Send as group message
if ($this->group) {
mail((string) $this->queue, $this->subject, $messageBody, $headers, $this->params);
// Else, Iterate through the queue and send the mail messages.
} else {
foreach ($this->queue as $rcpt) {
$subject = $this->subject;
$message = $messageBody;
// Set the recipient parameter.
$to = isset($rcpt['name']) ? $rcpt['name'] . " <" . $rcpt['email'] . ">" : $rcpt['email'];
// Replace any set placeholder content within the subject or message.
foreach ($rcpt as $key => $value) {
$subject = str_replace('[{' . $key . '}]', $value, $subject);
$message = str_replace('[{' . $key . '}]', $value, $message);
}
// Send the email message.
mail($to, $subject, $message, $headers, $this->params);
}
}
}