繁体   English   中英

通过 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 代码而不是那个模板,所以需要帮助我如何解决这个问题。

先感谢您。 我收到 html 代码而不是模板的邮件截图

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

添加这一行

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

此链接将为您提供帮助。
通过 PHP 在 email 中发送 HTML

提交时好像忘记包含 header,请在回复后将其添加到您的代码中

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

在你的 head 标签中使用这个元标签。你必须指定内容类型。否则它可以作为字符串。这就是为什么你的整个代码显示在邮件中。

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

function 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);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM