Jump to content

[SOLVED] Unknown error : PHP5 seams to be unable to echo it all...


XRayden

Recommended Posts

hello...

i've got a php class to validate form intry, it's supposed to send back the result in an email.

so far was working good, now i've got it to work on a PHP5 environment and it works, partialy...

here the error :

the faulty code reside in my html_mail() function :
[code]function html_mail()
{
$this->headers  = "MIME-Version: 1.0\n";
$this->headers .= "Content-type: text/html; charset=iso-8859-1\n";
$this->headers .= "X-Priority: 3\n";
$this->headers .= "X-MSMail-Priority: Normal\n";
$this->headers .= "X-Mailer: php\n";
$this->headers .= "From: \"".$this->fromname."\" <".$this->fromaddress.">\n";
return mail($this->to, $this->subject, stripslashes($this->message), $this->headers);
}[/code]

it was causing RANDOM unknown...

it works perfectly if my $this->to variable is set to [email protected]
and seams to NOT WORK if it's anything other than this one...

but here comes the part that thrown me out of my chair. it's not the $this->to that cauze the error!

check this out : i've modified the code to output some elements
[code]function html_mail()
{
$this->headers  = "MIME-Version: 1.0\n";
$this->headers .= "Content-type: text/html; charset=iso-8859-1\n";
$this->headers .= "X-Priority: 3\n";
$this->headers .= "X-MSMail-Priority: Normal\n";
$this->headers .= "X-Mailer: php\n";
echo $this->headers .= "From: \"".$this->fromname."\" <".$this->fromaddress.">\n";
echo '<br />';
echo $this->fromaddress;
echo '<br />';
echo $this->to;
return mail($this->to, $this->subject, stripslashes($this->message), $this->headers);
}[/code]

here is the output :
[code]MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: php From: "Olivier Labbé"
[email protected]
[email protected][/code]

php5 seams to shit the line :
$this->headers .= "From: \"".$this->fromname."\" <".$this->fromaddress.">\n";
and not being able to output the first "<" ... i've tried escaping it... dont work... any idea ?
As for PHP loosing the opening "<" in the echo statement. If you look at the source of the web page, you will see the character there. The problem is that the browser is eating it thinking that it is the beginning of a tag. To solve this problem, use the htmlentities() function when echoing the variable.

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.