Re: escaping quotes in mail() message
| From: | Lowell Allen | Date: | Mon, 03 Feb 2003 16:03:25 +0000 |
| Subject: | Re: escaping quotes in mail() message | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134138@lists.php.net to get a copy of this message | ||
> From: "1LT John W. Holmes" <holmes072000@charter.net>
>
>> I'm having a problem escaping double quotes in email messages sent with
>> mail(). The message is built as a string and assigned to a variable and
> the
>> variable name is passed to the mail function.
>>
>> The double quotes appear correctly in a simple test like this:
>> $message = "This message uses 'single' and \"double\"
>> quotes.";
>> mail($sendto, $subject, $message, $headers);
>>
>> But if $message is built in another part of the script and passed as a
>> hidden input of a form, the email arrives with the message truncated at
> the
>> first double quote encountered. If I do a str_replace() on $message to
>> escape double quotes, the email shows the escaping backslash but is still
>> truncated at the double quote!
[snip]
> The way around this is to use htmlentities() or htmlspecialchars() on your
> string before you insert it into the value attribute of your form element.
> It will come out decoded on the the other side, so you don't have to worry
> about that.
John, thanks for the fine reply -- problem solved!
--
Lowell Allen