/** * @param array $to * @param string $fromEmail * @param string $fromName * @param string $subject * @param string $body * @param string $contentType * @param array $cc * @param array $bcc * @return mixed */ function send(array $to, $fromEmail, $fromName, $subject, $body, $contentType = 'text/html', $cc = [], $bcc = []) { $message = new Message(); $message->setSubject($subject)->setFrom($fromEmail, $fromName); if ($contentType === 'text/html') { $message->setHtml($body)->setText(strip_tags($body)); } else { $message->setText($body); } foreach (['to' => 'addTo', 'cc' => 'addCc', 'bcc' => 'addBcc'] as $type => $method) { foreach (${$type} as $item) { if (is_array($item)) { $message->{$method}($item['email'], $item['name']); } else { $message->{$method}($item); } } } $this->getMandrill()->send($message); }