Beispiel #1
0
        } else {
            $attachments[] = (isnull($base) ? $base . '/' : '') . $filename;
        }
        return $this;
    }
    public function HtmlToTextBody($body = null)
    {
        if (is_null($body)) {
            $body = $this->_HTMLBody;
        }
        $lastligne = '';
        $tmpBody = utf8_decode($body);
        // on decode les caracteres encodés en utf-8 vers ISO-8859-1
        $tmpBody = preg_replace('!<title>(.*?)</title>!', '', $tmpBody);
        $tmpBody = preg_replace('!<a href(.*?)alt="(.*?)"(.*?)>(.*?)</a>!', "\\2", $tmpBody);
        $tmpBody = strip_tags($tmpBody);
        $tmpBody = str_replace("\r", "", $tmpBody);
        $tmpBodyArr = array();
        foreach (explode("\n", $tmpBody) as $ligne) {
            $ligne = trim($ligne);
            if (!($ligne == '' && $lastligne == '')) {
                $ligne = str_replace('&#149;', '-', $ligne);
                $tmpBodyArr[] = html_entity_decode($ligne);
            }
            $lastligne = $ligne;
        }
        return join("\n", $tmpBodyArr);
    }
}
smMailMessage::init();