protected function sendMailImpl($recipients, $subject, $body, $from = null, $images = array(), $useHtml = true) { require_once "lib/class.phpmailer-lite.php"; $realRecipients = $this->resolveAdresses($recipients); // NOW IF THERE ARE RECIPIENTS FOR ANY REASON, GO $mail = new PHPMailerLite(true); $mail->Mailer = $this->getFilteredOption("MAILER"); $mail->Sendmail = $this->getFilteredOption("SENDMAIL_PATH"); $from = $this->resolveFrom($from); if (!is_array($from) || empty($from["adress"])) { throw new Exception("Cannot send email without a FROM address. Please check your core.mailer configuration."); } if (!empty($from)) { if ($from["adress"] != $from["name"]) { $mail->SetFrom($from["adress"], $from["name"]); } else { $mail->setFrom($from["adress"]); } } foreach ($realRecipients as $address) { if ($address["adress"] == $address["name"]) { $mail->AddAddress(trim($address["adress"])); } else { $mail->AddAddress(trim($address["adress"]), trim($address["name"])); } } $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML($useHtml); // set email format to HTML $mail->CharSet = "utf-8"; $mail->Encoding = $this->getFilteredOption("MAIL_ENCODING"); foreach ($images as $image) { $mail->AddEmbeddedImage($image["path"], $image["cid"], '', 'base64', 'image/png'); } $mail->Subject = $subject; if ($useHtml) { if (strpos($body, "<html") !== false) { $mail->Body = $body; } else { $mail->Body = "<html><body>" . nl2br($body) . "</body></html>"; } $mail->AltBody = AjxpMailer::simpleHtml2Text($mail->Body); } else { $mail->Body = AjxpMailer::simpleHtml2Text($body); } if (!$mail->Send()) { $message = "Message could not be sent\n"; $message .= "Mailer Error: " . $mail->ErrorInfo; throw new Exception($message); } }