/** * @param $email_to * @param $rendered_template * @param string $mailer_alias * @param array $tags * @return bool * @throws \Exception */ public function sendMail($email_to, $rendered_template, $mailer_alias = null, $tags = array()) { $renderedLines = explode($this->keybund, trim($rendered_template)); $subject = $renderedLines[0]; $body = implode($this->keybund, array_slice($renderedLines, 1)); $message = new Message(); $message->setSubject($subject)->addTo($email_to)->setHtml($body); if ($this->senderName) { $message->setFromName($this->senderName); } if ($this->from) { $message->setFromEmail($this->from); } if ($mailer_alias) { $message->setSubaccount($mailer_alias); } foreach ($tags as $tag) { $message->addTag($tag); } foreach ($this->attachs as $attach) { $message->addAttachment($attach['type'], $attach['name'], $attach['data']); } foreach ($this->parts as $part) { $message->addPart($part['body'], $part['type']); } $this->attachs = array(); $this->parts = array(); $this->logger->info(sprintf('Send Mandrill mail to : %s using subaccount "%s". Subject : "%s"', $email_to, $mailer_alias, $this->dkimDomain ? 'yes' : 'no', $subject)); $errors = null; $this->mandrill->send($message); return $errors; }
/** * @param string $renderedTemplate * @param string $fromEmail * @param string $toEmail */ protected function sendEmailMessage($renderedTemplate, $toEmail) { // Render the email, use the first line as the subject, and the rest as the body $renderedLines = explode("\n", trim($renderedTemplate)); $subject = $renderedLines[0]; $body = implode("\n", array_slice($renderedLines, 1)); $message = new Message(); $message->setFromName('Equipo Juzz')->addTo($toEmail)->setSubject($subject)->setHtml($body); $result = $this->dispatcher->send($message); $this->logger->info("Result Mail"); $this->logger->info(print_r($result)); }