PHPMailer\PHPMailer

PHPMailer::html2text()publicWP 1.0

Convert an HTML string into plain text. This is used by msgHTML(). Note - older versions of this function used a bundled advanced converter which was removed for license reasons in #232. Example usage:

//Use default conversion
$plain = $mail->html2text($html);
//Use your own custom converter
$plain = $mail->html2text($html, function($html) {
	$converter = new MyHtml2text($html);
	return $converter->get_text();
});

Method of the class: PHPMailer{}

No Hooks.

Return

String.

Usage

$PHPMailer = new PHPMailer();
$PHPMailer->html2text( $html, $advanced );
$html(string) (required)
The HTML text to convert
$advanced(true|false|callable)
Any boolean value to use the internal converter, or provide your own callable for custom conversion.
Never pass user-supplied data into this parameter
Default: false

PHPMailer::html2text() code WP 6.4.3

public function html2text($html, $advanced = false)
{
    if (is_callable($advanced)) {
        return call_user_func($advanced, $html);
    }

    return html_entity_decode(
        trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
        ENT_QUOTES,
        $this->CharSet
    );
}