Sets the HTML body for the message

@param  string    $html
@param  string    $charset
@param  string    $encoding
@return \Zend_Mail
559125
public function setBodyHtml($html, $charset = null, $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE)
    {
        $this->setType(\Zend_Mime::MULTIPART_RELATED);

        $dom = new \DOMDocument(null, $this->getCharset());
        @$dom->loadHTML($html);

        $images = $dom->getElementsByTagName('img');
        for ($i = 0; $i < $images->length; $i++) {
            $img = $images->item($i);
            $url = $img->getAttribute('src');

            try {
                $client = new \Zend_Http_Client($url);
                $response = $client->request();

                if ($response->getStatus() === 200) {
                    $imageContent = $response->getBody();

                    $pathinfo = pathinfo($url);
                    $mimeType = $response->getHeader('Content-Type');

                    $cid = md5($pathinfo['filename']);
                    $html = str_replace($url, 'cid:' . $cid, $html);

                    $mime = new \Zend_Mime_Part($imageContent);
                    $mime->id = $cid;
                    $mime->type = $mimeType;
                    $mime->disposition = \Zend_Mime::DISPOSITION_INLINE;
                    $mime->encoding = \Zend_Mime::ENCODING_BASE64;
                    $mime->filename = $pathinfo['basename'];

                    $this->addAttachment($mime);
                }
            } catch (\Exception $exc) {
                //Error on client connect - bad url?
            }
        }

        return parent::setBodyHtml($html, $charset, $encoding);
    }
1359683
public function getHtmlContent($index = 0, $charset = MailMimeParser::DEFAULT_CHARSET)
    {
        $part = $this->getHtmlPart($index);
        if ($part !== null) {
            return $part->getContent($charset);
        }
        return null;
    }
11683
public function setContentHeader($contentType, $charset = 'UTF-8')
    {
        if (!$this->response) {
           return $this->getResponse()->setContentHeader($contentType, $charset);
        }
        return parent::setContentHeader($contentType, $charset);
    }
1329445
public static function Purify($html = null, $encoding = 'UTF-8') {

		$config = self::GetHTMLPurifierConfig();
		$config->set('Core.Encoding', $encoding);
		$config->set('HTML.Allowed', 'span,p,br,a,h1,h2,h3,h4,h5,strong,em,u,ul,li,ol,hr,blockquote,sub,sup,p[class],img');
		$config->set('HTML.AllowedElements', array('span', 'p', 'br', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'strong', 'em', 'u', 'ul', 'li', 'ol', 'hr', 'blockquote', 'sub', 'sup', 'img'));
		$config->set('HTML.AllowedAttributes', 'style,target,title,href,class,src,border,alt,width,height,title,name,id');
		$config->set('CSS.AllowedProperties', 'text-align,font-weight,text-decoration');
		$config->set('AutoFormat.RemoveEmpty', true);
		$config->set('Attr.ForbiddenClasses', array('MsoNormal'));

		$purifier = new \HTMLPurifier($config);
		return $cleanCode = $purifier->purify($html);
	}
636921
public function setContent($resource, $charset = MailMimeParser::DEFAULT_CHARSET)
    {
        $stream = Psr7\stream_for($resource);
        $this->attachContentStream($stream, $charset);
        // this->onChange called in attachContentStream
    }
763911
public static function contentType($type, $charset = 'utf-8'){
        $type = isset( self::$types[$type] ) ? self::$types[$type] : $type;
        self::set('Content-Type: '. $type. '; charset='. $charset);
    }
472919
public function charset($charset = null)
    {
        if (!func_num_args()) {
            return $this->_stream->charset();
        }
        $this->_stream->charset($charset);
        return $this;
    }
1208884
public function htmlSpecialCharacters($flags = ENT_HTML5, string $encoding = 'UTF-8', bool $doubleEncode = true) : Manipulator
    {
        return new static(htmlspecialchars($this->string, $flags, $encoding, $doubleEncode));
    }
1049736
public function setCharset($charset)
    {
        if ($this->config->getCharset() !== $charset) {
            $this->config->setCharset($charset);
            if ($this->connection) {
                $this->query('SET NAMES ?', [$charset]);
            }
        }

        return $this;
    }
1187330
public function setText($content, $charset = 'utf-8') {
        $this->text = $content;
        $this->textCharset = $charset;
        return $this;
    }
1361488
public function process($value = '', $format = 'html', $charset = null)
    {
        if ($charset === null) {
            $charset = $this->core->getCharset();
        }

        switch ($format) {
            case 'html':
                return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
            case 'htmlall':
                return htmlentities((string)$value, ENT_QUOTES, $charset);
            case 'url':
                return rawurlencode((string)$value);
            case 'urlpathinfo':
                return str_replace('%2F', '/', rawurlencode((string)$value));
            case 'quotes':
                return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
            case 'hex':
                $out = '';
                $cnt = strlen((string)$value);
                for ($i = 0; $i < $cnt; ++ $i) {
                    $out .= '%' . bin2hex((string)$value[$i]);
                }

                return $out;
            case 'hexentity':
                $out = '';
                $cnt = strlen((string)$value);
                for ($i = 0; $i < $cnt; ++ $i) {
                    $out .= '&#x' . bin2hex((string)$value[$i]) . ';';
                }

                return $out;
            case 'javascript':
            case 'js':
                return strtr((string)$value,
                    array(
                        '\\' => '\\\\',
                        "'"  => "\\'",
                        '"'  => '\\"',
                        "\r" => '\\r',
                        "\n" => '\\n',
                        '</' => '<\/'
                    ));
            case 'mail':
                return str_replace(array(
                    '@',
                    '.'
                ),
                    array(
                        '&nbsp;(AT)&nbsp;',
                        '&nbsp;(DOT)&nbsp;'
                    ),
                    (string)$value);
            default:
                $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "' . $format . '" given.',
                    E_USER_WARNING);
        }
    }
424003
public function setBody($body, $html = false)
    {
        Argument::i()
            ->test(1, 'string')
            ->test(2, 'bool');

        if ($html) {
            $this->body['text/html'] = $body;
            $body = strip_tags($body);
        }

        $this->body['text/plain'] = $body;

        return $this;
    }
994397
public static function newDocumentXHTML($markup = null, $charset = null) 
    {
        $contentType = $charset
        ? ";charset=$charset"
        : '';
        return self::newDocument($markup, "application/xhtml+xml{$contentType}");
    }
932150
public function escapeHTML(?string $string, string $charset, bool $doubleEncode = true): string
	{
		return htmlspecialchars($string, ENT_QUOTES, $charset, $doubleEncode);
	}
162422
public function charset($charset, $convert = true)
    {
        $oldcharset = $this->_charset;
        $this->_charset = Horde_String::upper($charset);

        if (!$convert || ($oldcharset == $this->_charset)) {
            return;
        }

        foreach (array('and', 'or') as $item) {
            if (isset($this->_search[$item])) {
                foreach ($this->_search[$item] as &$val) {
                    $val->charset($charset, $convert);
                }
            }
        }

        foreach (array('header', 'text') as $item) {
            if (isset($this->_search[$item])) {
                foreach ($this->_search[$item] as $key => $val) {
                    $new_val = Horde_String::convertCharset($val['text'], $oldcharset, $this->_charset);
                    if (Horde_String::convertCharset($new_val, $this->_charset, $oldcharset) != $val['text']) {
                        throw new Horde_Imap_Client_Exception_SearchCharset($this->_charset);
                    }
                    $this->_search[$item][$key]['text'] = $new_val;
                }
            }
        }
    }
853584
private function renderHtml(&$content, $html, $encoding, $boundary)
    {
        $content .= "\r\n";
        $content .= "--$boundary\r\n";
        $content .= "Content-Type: text/html;\r\n\tcharset=\"$encoding\"\r\n";
        $content .= "Content-Transfer-Encoding: quoted-printable\r\n";
        $content .= "\r\n";
        $content .= "$html\r\n";
    }
771354
public function setCharset($charset)
    {
        $this->charset = $charset;
        $this->setContentType($this->getContentType()); // update charset which is set on content-type

        return $this;
    }