通过 phpmailer 发送邮件并且它工作正常但问题是我在其中插入了一个模板并且我正在接收该模板的代码

sending mail through phpmailer and its working properly but the problem is i have inserted one templet in it and i am receiving code of that templet

<?php   
function sendCOTP($REmail,$RVID) {
                $to      = $REmail;
                    $subject = 'Allloooooooooooo Bhindiiiiiii';
                    ob_start();
                    include './mailtemplet.php';
                    $body = ob_get_clean();
                    
                    $message = 'Dear,sir'
                            . 'Guess what ??? '.$RVID.' venue that you checked earlear is now finallyyy available so check it out and book it before again it get booked '
                            . 'Thank you'
                            . 'team venueazy';
                    $headers = 'From: bookvenue01@gmail.com'       . "\r\n" .
                                 'Reply-To: bookvenue01@gmail.com' . "\r\n" .
                                 'X-Mailer: PHP/' . phpversion();

                    mail($to, $subject,$body, $message, $headers);
}

?>

所以这里一切正常,但是我包含的模板不起作用,就像我得到的是 html 代码而不是那个模板,所以需要帮助我如何解决这个问题。

提前谢谢你。Mail screenshot where i am getting html code instead of templet

需要帮助我如何制作“IsHTML(true);”在我的代码中?

添加这一行

$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

这篇link会对你有所帮助。
Send HTML in email via PHP

您提交时似乎忘记包含 header,请在 Reply-To

之后将其添加到您的代码中
$headers .= "Content-Type: text/html;\r\n";

在您的 head 标签中使用此元标签。您必须指定内容 type.else 它可以作为 string.that 为什么您的整个代码显示在邮件中的原因。

 <meta http-equiv="Content-Type"  content="text/html charset=UTF-8" />

函数 sendCOTP($REmail,$RVID) { $to = $REmail;

                    $subject = 'Venue is Available';

                    $headers = 'From:bookvenue01@gmail.com';
                    $headers .= 'Reply-To: bookvenue01@gmail.com' . "\r\n";
                    $headers .= "MIME-Version: 1.0\r\n";
                    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";

                    $email_template = './mailtemplet.html';
                    
                    $message = file_get_contents($email_template);

                    mail($to, $subject, $message, $headers);
}