Can phpmailer's $mail- > Body be included in a file?

$mail->Body = "";

when I find that I want to send a letter, I will write a whole html + css phrase, and then add a php phrase
like:

$mail->Body = "
    <html>
    <head>
    ".$phpmailerCssStyle."
    </head>

    <body>
    <div class="edm-layout">
      <img src="".$host_url."images/logo.png">
      <div class="line"></div>
    </div>

    <div class="edm-content">
      <div class="edm-hithere">
        ".$getUser["name"]." <br> ".$prodTotal." <br>".formatProductPrice($thisTotal)." 
      </div>";

        $row_distinct = mysqli_fetch_array($cako_id_distinct);

        $cako_data = $pdo->query(
          "SELECT  "
        );
        $mail->Body .= "
        <div class="edm-products">
          ".$row_distinct[""];
          
          //.......
          
          </body>
    </html>
The

type is like the long code
can I import it into a file as long as the list is introduced?

$mail->Body = "xxx.php"; or require_once...

is there any legal truth?
or some other way?
at least my code on this page will not see this long string of codes.

May.30,2021

the code written above is extremely dangerous

it is recommended that the content embedded with HTML be stored by using the template file , and replace with the placeholder in the form of placeholder.

suggested scheme

  • email.template

:<br>$mail->Body = 'xxx.php'; or require_once...<br>

$body = get_file_contents('xxx.html');
$body = str_replace('{{head}}',$head,$body);
$body = str_replace('{{contant}}',$contant,$contant);
$mail->Body = $body;
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c3bc-40884.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c3bc-40884.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?