Welcome to WebmasterWorld Guest from 54.221.119.45

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Mail() unwanted escapes (backslashes)

Thanks in advance for all help!

     

realestatesteve

7:16 pm on Dec 17, 2008 (gmt 0)

5+ Year Member



I'm currently using a PHPMailer class to send emails from my application. There is this one pesky problem that I can't spot, which is that it is escaping all apostrophes in the final email that's sent.

I know that I do need to escape the normal problematic characters, but is there any way to remove the backslash after sending the email - or right before sending it?

Example: User sends email with this as body:

"Hi there, John! It's been great talking to you."

Resulting email:

"Hi there, John! It\'s been great talking to you."

[edited by: eelixduppy at 8:12 pm (utc) on Dec. 17, 2008]
[edit reason] removed URL [/edit]

The Contractor

7:32 pm on Dec 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



probably mod_security running on the server as it will escape quotes and apostrophes

realestatesteve

7:45 pm on Dec 17, 2008 (gmt 0)

5+ Year Member



Hmm; I don't think it's safe to turn that off. What do you think I could do to work around it?

I just did a test to see what $_POST['message'] was sending across, and it was in fact escaped from the get go. PHPMailer doesn't have anything to do with it.

So hmm; need to find why my server adds the slashes automatically, and if it's safe to turn them off.

The Contractor

7:55 pm on Dec 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure, maybe someone else will chime in as I do not know of a "fix".

realestatesteve

7:59 pm on Dec 17, 2008 (gmt 0)

5+ Year Member



Ah, hah! stripslashes() looks to do the trick. :) I also tested it with commas, quotations, and the mail is sent fine without errors.

Is there anything wrong with doing it this way?

milocold

11:05 am on Dec 18, 2008 (gmt 0)

10+ Year Member



Hi,

Sounds to me like magic_quotes is the culprit. You can check your server\'s setting on this using:

<?php echo get_magic_quotes_gpc(); ?>

As for stripslashes, there\'s nothing wrong with using it in these circumstances.

-M. Cold

 

Featured Threads

Hot Threads This Week

Hot Threads This Month