Search code examples
phpphpmailer

PHPMailer send mail like text, but isHTML = true


$mail = new PHPMailer;
$mail->setFrom('info@example.pro', 'KitApp');
$mail->addAddress('info@example.pro');
$mail->addAddress('topsuak@example.com');
$mail->addAddress('lexxsumy@example.com');
$mail->addAddress('sales@example.pro');
$mail->Subject = 'example - оценка проекта';
$mail->isHTML(true);
$mail->Body = '<div>
    <h2>Клиент выполнил оценку проекта.</h2>
    <p>Имя: <b>'. 'sdfsdf' .'</b></p>
    <p>Контакты: <b>'.'sadsad'.'</b></p>
</div>';
$mail->CharSet = "UTF-8";

this code sending message with HTTP headers like text:

This is a multi-part message in MIME format.

--b1_kMw0lvaLD8a9kzvOpaPvFScTz5hnroHb3FHDBNGivk

Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<div>
<h2>Клиент выполнил оценку проекта.</h2>
<p>Имя: <b>бек1</b></p>
<p>Контакты: <b>тест</b></p>
</div>

Solution

  • what version of php?

    if php8 try to edit PHPMailer.php like this

    const CRLF = "\n";
    protected static $LE = "\n";
    

    this help for me

    additional info about this bug https://bugs.php.net/bug.php?id=81158