homepage Welcome to WebmasterWorld Guest from 23.22.217.122
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Mail() unwanted escapes (backslashes)
Thanks in advance for all help!
realestatesteve




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

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




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

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

realestatesteve




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

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




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

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

realestatesteve




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

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




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved