src/Mime/Message.php
public function html($body, $basePath = null)
    {
        if (!func_num_args()) {
            return $this->_body;
        }

        if ($basePath) {
            $cids = [];
            $hasInline = preg_match_all('~
                (<img[^<>]*\s src\s*=\s*
                |<body[^<>]*\s background\s*=\s*
                |<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
                |<style[^>]*>[^<]+ [:\s] url\()
                (["\']?)(?![a-z]+:|[/#])([^"\'>)\s]+)
                |\[\[ ([\w()+./@\\~-]+) \]\]
            ~ix', $body, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
            if ($hasInline) {

                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->addInline($file), 1, -1);
                    }
                    $body = substr_replace($body, "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}", $m[0][1], strlen($m[0][0]));
                }
            }
        }

        $this->body($body);
        $this->mime('text/html');
        $this->charset(Mime::optimalCharset($body));

        $this->_altBody = static::stripTags($this->_body);
        return $this;
    }
public function html($body, $basePath = null)
    {
        if (!func_num_args()) {
            return $this->_body;
        }

        if ($basePath) {
            $cids = [];
            $hasInline = preg_match_all('~
                (<img[^<>]*\s src\s*=\s*
                |<body[^<>]*\s background\s*=\s*
                |<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
                |<style[^>]*>[^<]+ [:\s] url\()
                (["\']?)(?![a-z]+:|[/#])([^"\'>)\s]+)
                |\[\[ ([\w()+./@\\~-]+) \]\]
            ~ix', $body, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
            if ($hasInline) {

                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->addInline($file), 1, -1);
                    }
                    $body = substr_replace($body, "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}", $m[0][1], strlen($m[0][0]));
                }
            }
        }

        $this->body($body);
        $this->mime('text/html');
        $this->charset(Mime::optimalCharset($body));

        $this->_altBody = static::stripTags($this->_body);
        return $this;
    }
public function html ( $ body , $ basePath = null ) { if ( ! func_num_args ( ) ) { return $ this -> _body ; } if ( $ basePath ) { $ cids = [ ] ; $ hasInline = preg_match_all ( '~
                (<img[^<>]*\s src\s*=\s*
                |<body[^<>]*\s background\s*=\s*
                |<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
                |<style[^>]*>[^<]+ [:\s] url\()
                (["\']?)(?![a-z]+:|[/#])([^"\'>)\s]+)
                |\[\[ ([\w()+./@\\~-]+) \]\]
            ~ix' , $ body , $ matches , PREG_OFFSET_CAPTURE | PREG_SET_ORDER ) ; if ( $ hasInline ) { 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 -> addInline ( $ file ) , 1 , - 1 ) ; } $ body = substr_replace ( $ body , "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}" , $ m [ 0 ] [ 1 ] , strlen ( $ m [ 0 ] [ 0 ] ) ) ; } } } $ this -> body ( $ body ) ; $ this -> mime ( 'text/html' ) ; $ this -> charset ( Mime :: optimalCharset ( $ body ) ) ; $ this -> _altBody = static :: stripTags ( $ this -> _body ) ; return $ this ; }
Set the HTML body message with an optionnal alternative body.

@param  string      $body    The HTML body message.
@param  string      $altBody The alt body.
@return string|self
Set the HTML body message with an optionnal alternative body .