Forum Moderators: coopster

Message Too Old, No Replies

shows html code while sending mail problem?

         

PHPycho

9:24 am on Jun 8, 2007 (gmt 0)

10+ Year Member



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:
[php]<?php
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
<html>
<head>
</head>
<body>

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

</table>

</body>
</html>
EOF;
$this->message = $message;
}

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

}

/**
* Usage
*/

$Mailer = new Mailer();
$Mailer->setSubject();
$Mailer->setMessage("Message goes here...");
$Mailer->sendMail();
?>[/php]
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

henry0

11:22 am on Jun 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure I see clearly what your problem is?
Are you for example having a mail consisting of a PHP based script and sending it out via Outlook express?

if so it won't work; (I believe)- MS outlook is not a PHP parser so your code needs to be server side “served” and mailed out of the mail server then the PHP will be exec.