tags:

views:

32

answers:

4

Hello,

This is a simple issue but I have been unable to solve this. My problem is that I am sending email using the libmail class.

$message = htmlspecialchars(stripslashes(strip_tags($message)));

Everything is working fine but if I use the " in the text, it will be diaslayed in the mail as ". I have already tried:

mail ($strTo, $this->xheaders['Subject'], htmlentities($this->fullBody), $this->headers,"-f $rtpth");

How to solve this?

+3  A: 

Leave out the htmlspecialchars and htmlentites calls, they are converting your quotes to html entites, which means that your " character is converted to & quot;

Palantir
+1 Good advice. You should only need to call htmlspecialchars for data that will be printed as HTML.
Spudley
A: 

If you're using a recent version of PHP (v5.1 or better), you can use htmlspecialchars_decode to .. uh... decode htmlspecialchars.

See here for the manual page: http://php.net/manual/en/function.htmlspecialchars-decode.php

Spudley
+1  A: 

You don't need to use htmlspecialchars when defining $message

By the way, for decoding html entities - http://lv.php.net/manual/en/function.html-entity-decode.php

Māris Kiseļovs
A: 

set ENT_NOQUOTES, " should then not be replaced htmlspecialchars($string,ENT_NOQUOTES)http://php.net/manual/de/function.htmlspecialchars.php

Hannes
he is probably just misusing htmlentities and htmlspecialchars. This will render those functions useless in other context and may weaken security.
Palantir
well, if you have a Problem with his code vote his question down, not a legit Answer how to prevent htmlspecialchars from converting quotes... jezz ...
Hannes