XRayden Posted January 10, 2007 Share Posted January 10, 2007 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 info@xagone.comand 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é"info@xagone.comemploisofferts@publicationweb.com[/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 ? Quote Link to comment Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 To keep it simple, try....[code=php:0]$this->headers .= "From: \"{$this->fromname}\" <{$this->fromaddress>}\n";[/code] Quote Link to comment Share on other sites More sharing options...
XRayden Posted January 10, 2007 Author Share Posted January 10, 2007 still doesn't work... is there a way to know WHY the mail() is returning false ? Quote Link to comment Share on other sites More sharing options...
emehrkay Posted January 10, 2007 Share Posted January 10, 2007 why are you setting the headers var as a property of the class? will you use it somewhere else in the class? if not just do $header = ...that may cause your problem Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 10, 2007 Share Posted January 10, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.