public static function sendEmail($subject, $from, $to, $title, $body, $language = 'en', $html = true, $attach = array()) { self::init(); // Check that $to/$from are both arrays $from = is_array($from) ? $from : explode(',', $from); $to = is_array($to) ? $to : explode(',', $to); //Create the message $message = self::getSwift()->setSubject($subject)->setFrom($from)->setTo($to); // Purify HTML. All tags for forum posts + <hr> for the footer separation $purifier = MOD_htmlpure::get()->getMailHtmlPurifier(); $body = $purifier->purify($body); $html2text = new Html2Text\Html2Text($body, false, array('do_links' => 'table', 'width' => 75)); $plain = $html2text->getText(); $message->setBody($plain); // $message->addPart($plain, 'text/plain'); // Add the html-body only if the member wants HTML mails if ($html) { // Translate footer text (used in HTML template) $words = new MOD_words(); $footer_message = $words->getPurified('MailFooterMessage', array(date('Y')), $language); // Using a html-template ob_start(); require SCRIPT_BASE . 'templates/shared/mail_html.php'; $mail_html = ob_get_contents(); ob_end_clean(); $message->addPart($mail_html, 'text/html'); } return self::sendSwift($message); }