/** * @param Mail $mail * @throws MailException */ public function send(Mail $mail) { $body = $mail->getHtmlOrText(); $message = array('subject' => $mail->getSubject(), 'to' => $this->getTo($mail), 'images' => $this->getImages($mail)); if ($mail->isHTML()) { $message['html'] = $body; } if ($text = $mail->getText()) { $message['text'] = $text; } if ($mail->getFrom()) { $message['from_email'] = $mail->getFrom()->getEmail(); if ($mail->getFrom()->getName()) { $message['from_name'] = $mail->getFrom()->getName(); } } else { throw new MailException("Mandrill requires a FROM email address to be set."); } $headers = array(); if ($mail->getReplyTo()) { $headers['Reply-To'] = $mail->getReplyTo()->getEmail(); } if (count($headers) > 0) { $message['headers'] = $headers; } $result = $this->mandrill->messages->send($message); }