Sets HTML body.

@param string      $html
@param string|null $basePath

@return $this

@throws RegexpException
761835
public function setHtmlBody(string $html, string $basePath = null)
    {
        if ($basePath) {
            $cids = [];
            $matches = Strings::matchAll(
                $html,
                '#
					(<img[^<>]*\s src\s*=\s*
					|<body[^<>]*\s background\s*=\s*
					|<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
					|<style[^>]*>[^<]+ [:\s] url\()
					(["\']?)(?![a-z]+:|[/\\#])([^"\'>)\s]+)
					|\[\[ ([\w()+./@~-]+) \]\]
				#ix',
                PREG_OFFSET_CAPTURE
            );
            foreach (\array_reverse($matches) as $m) {
                $file = \rtrim($basePath, '/\\') . '/' . (isset($m[4]) ? $m[4][0] : \urldecode($m[3][0]));
                if (!isset($cids[$file])) {
                    $cids[$file] = \substr($this->addEmbeddedFile($file)->getHeader('Content-ID'), 1, -1);
                }
                $html = \substr_replace($html,
                    "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}",
                    $m[0][1], \strlen($m[0][0])
                );
            }
        }

        if ($this->getSubject() == null) { // intentionally ==
            $html = Strings::replace($html, '#<title>(.+?)</title>#is', function (array $m): void {
                $this->setSubject(\html_entity_decode($m[1], ENT_QUOTES, 'UTF-8'));
            });
        }

        $this->htmlBody = \ltrim(\str_replace("\r", '', $html), "\n");

        if ($html !== '' && $this->getBody() === '') {
            $this->setBody($this->buildText($html));
        }

        return $this;
    }
1309462
public function setBasePath($path) {
		$path = rtrim($path, DIRECTORY_SEPARATOR);
		
		if (! file_exists($path) || ! is_dir($path)) {
			throw new ConfigError('Base directory does not exists: "' . $path . '"');
		}
		
		$this->_basePath = $path;
		
		return $this;
	}
30181
public function setBody($content, $type = 'text/html', $charset = 'utf-8')
    {
        $this->message->setBody($content, $type, $charset);

        return $this;
    }
1112043
public function prependHtml($html)
    {
        $this->each(function ($item) use ($html) {
            $item->title = $html . $item->title;
        });

        return $this;
    }
239829
public static function getBodyNodeFromHtmlFragment($html, $charset = 'UTF-8')
    {
        $html = '<html><body>' . $html . '</body></html>';
        $current = libxml_use_internal_errors(true);
        $disableEntities = libxml_disable_entity_loader(true);
        $d = new \DOMDocument('1.0', $charset);
        $d->validateOnParse = true;
        if (function_exists('mb_convert_encoding') && in_array(
                strtolower($charset),
                array_map('strtolower', mb_list_encodings())
            )
        ) {
            $html = mb_convert_encoding($html, 'HTML-ENTITIES', $charset);
        }
        @$d->loadHTML($html);
        libxml_use_internal_errors($current);
        libxml_disable_entity_loader($disableEntities);
        return $d->getElementsByTagName('body')->item(0);
    }
643515
public function addHTML ($html, $plain = FALSE)
    {

        // Set the HTML boolean to true

        $this->_htmlSet	= TRUE;

        // If there is a plain equivalent

        if ($plain)
        {

            // Add it to the plain array

            $this->addPlain ($plain);

        }

        // Add the HTML to the HTML array

        $this->_html[]	= $html;

    }
493687
public function setBasePath($basePath = null) {
        if ($basePath === null) {
            $filename = (isset($this->SERVER['SCRIPT_FILENAME']))
                      ? basename($this->SERVER['SCRIPT_FILENAME'])
                      : '';

            $baseUrl = $this->getBaseUrl();
            if (empty($baseUrl)) {
                $this->_basePath = '';
                return $this;
            }

            if (basename($baseUrl) === $filename) {
                $basePath = dirname($baseUrl);
            } else {
                $basePath = $baseUrl;
            }
        }

        if (substr(PHP_OS, 0, 3) === 'WIN') {
            $basePath = str_replace('\\', '/', $basePath);
        }

        $this->_basePath = rtrim($basePath, '/');
        return $this;
    }
1199321
public function withBasePath($basePath)
    {
        if (!is_string($basePath)) {
            throw new InvalidArgumentException('Uri path must be a string');
        }
        if (!empty($basePath)) {
            $basePath = '/' . trim($basePath, '/'); // <-- Trim on both sides
        }
        $clone = clone $this;

        if ($basePath !== '/') {
            $clone->basePath = $this->filterPath($basePath);
        }

        return $clone;
    }
742266
public function setBaseUrl($baseUrl)
    {
        if ($baseUrl) {
            if (UrlHelper::isUrl($baseUrl)) {
                $this->baseUrl = rtrim($baseUrl, '/') . '/';
            } else {
                $this->baseUrl = rtrim($baseUrl, '/') . '/';
            }
        }

        return $this;
    }
497206
protected function initBaseDir($basePath)
    {
        if ($basePath) {
            $this->setBaseDir($basePath);
        } elseif (defined('BASE_PATH')) {
            $this->setBaseDir(BASE_PATH);
        } else {
            throw new BadMethodCallException("No BASE_PATH defined");
        }
    }
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);
    }
1178498
public function setBody($body, $contentType = null, $charset = null)
    {
        if (isset($charset)) {
            $this->setCharset($charset);
        }
        $body = $this->convertString($body);

        parent::setBody($body, $contentType);

        return $this;
    }
1318362
public function setBody($body)
    {
        $node = $this->getBody(false);
        if(!$node){
            $node = $this->createElement('body');
            $this->doc->appendChild($node);
        }
        $node->nodeValue = htmlspecialchars($body);
    }
562255
public function basePath($basePath = null)
    {
        if (!func_num_args()) {
            return $this->_basePath;
        }
        $this->_basePath = $basePath;
        return $this;
    }
496132
public function createApplication(?string $basePath = null): self
    {
        $basePath ?: $basePath = realpath(__DIR__.'/../../../../../');

        $this->app = new Application($basePath);

        return $this;
    }
109067
public function setBasePath($path) {
		$path = rtrim($path, '\/');
		
		if (preg_match('~^[a-z]+:~', $path)) {
			$this->basePath = $path;
			return;
		}
		
		$this->basePath = realpath($path);
		
		return $this;
	}
427826
public function discoverFromHtml($html)
    {
        $links = $this->findLinks($html);

        if ( ! $link = reset($links)) {
            return;
        }

        $type = null;

        switch($link['type']) {
        case 'application/json+oembed':
            $type = Provider::TYPE_JSON;
            break;
        case 'text/xml+oembed':
            $type = Provider::TYPE_XML;
            break;
        }

        $url = $link['href'];
        $endpoint = $this->getEndpointUrl($url);

        return new Provider($endpoint, $type);
    }