'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: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject,$body, $message, $headers);
}
?>
so here everything is working fine but the templet which i have included that is not working like i am getting html code instead of that templet so need help with that how can i solve this issue.
thank you in advance.Mail screenshot where i am getting html code instead of templet
need help is how can i make "IsHTML(true);" in my code?
Solution 1:[1]
function sendCOTP($REmail,$RVID) { $to = $REmail;
$subject = 'Venue is Available';
$headers = 'From:[email protected]';
$headers .= 'Reply-To: [email protected]' . "\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);
}
Solution 2:[2]
It looks like you forgot to include a header when submitting, add this to your code after Reply-To
$headers .= "Content-Type: text/html;\r\n";
Solution 3:[3]
use this meta tag inside your head tag .you must specify content type.else it can be take it as string.that's why your whole code displayed in mail.
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
Solution 4:[4]
Add this line
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
This link will help you.
Send HTML in email via PHP
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bhavik |
| Solution 2 | Harvey Dent |
| Solution 3 | |
| Solution 4 | gre_gor |
