View Full Version : shows html code while sending mail problem ??

06-08-2007, 11:19 AM
Hello forums !!
I am using my mail function to send the mail, mail successfully goes but the problem is its shows all the html codes and also the name is blank in the from section (Note: I am using outlook express)
i had used the following code:

class Mailer{
var $to;
var $from;
var $cc;
var $bcc;
var $headers;
var $subject;
var $message;

function Mailer(){
$this->to = "";
$this->from = "";
$this->cc = "";
$this->bcc = "";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: '.$this->to . "\r\n";
$headers .= 'From: '.$this->from . "\r\n";
$headers .= 'Reply-To: '.$this->from . "\r\n";
$headers .= 'Cc: '.$this->cc . "\r\n";
$headers .= 'Bcc: '.$this->bcc . "\r\n";
$this->headers = $headers;

function setSubject(){
$this->subject = "subjects goes here..";

function setMessage($message){
# set Message
$message = <<<EOF

<table width="455" border="0" align="center" cellpadding="0" cellspacing="10" bgcolor="#FFFFFF">
<td width="88"><span class="field">Message</span></td>
<td width="289"><span class="fieldValue">$message</span></td>


$this->message = $message;

function sendMail(){
return mail($this->to, $this->subject, $this->message, $this->headers);


* Usage

$Mailer = new Mailer();
$Mailer->setMessage("Message goes here...");
How to make the code working (ie output should displayed as text not the code and also the from section should be visible (Note i m using outlook express))
Thanks in advance to all of you