[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

php Mail

Posted on 2006-10-31
7
Medium Priority
?
187 Views
Last Modified: 2010-04-06
I'm using the php mail function to send structured emails based on data entered on web forms.

Some of the data entered MAY have single quote or double quote characters in the text. We want the email to reflect EXACTLY what's entered.

It appears that the php mail function "escapes" special characters. So, for example, if the input was O'Hanlon, the email message contains
Customer Name: O\'Hanlon

Is there a way to disable php mail from "escaping" these characters?

If not, is there anither "open source" mail package that doesn't do this?

0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 17845688
Are you sure magic quotes is not on?
Try this line before you send the mail:
set_magic_quotes_runtime(0);
0
 

Author Comment

by:Richard Korts
ID: 17845885
To TeRRef,

I never heard of set_magic_quotes, but I looked it up.

I tried it but it didn't work. However, I forgot to mention that the actual character at that time is the ` not the ', because I changed all the ' to ` to avoid SQL database insert problems.

Does set_magic_quotes deal with ` also or do I have to send the email AND THEN change ' to `?

Thanks
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 2000 total points
ID: 17845988
I don't understand why you're affraid of INSERT problems while sending mail? If you mean that you changed the chars before you put the names in the DB, there are better ways of doing that. THere is a neat function called mysql_real_escape_string() that handles these potential problems for you:
http://php.net/mysql_real_escape_string

I don't think set_magic_quotes deals with the ` char.

ANyway, I'm not sure why the mail function escapes on it's own. Can't recall ever having these problems. But then again, I usually use PHPMailer for these tasks since it's much better equiped. Maybe you can give that a try:
http://sourceforge.net/projects/phpmailer/
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Richard Korts
ID: 17846035
To TeRRef,

I'm not afraid of INSERT problems while sending mail. It's just that the sequence of my logic in the php program converted all the ' to ` BEFORE I sent the email because the sending of the mail was an added on requirement.

I know about mysql_real_escape_string() but it doesn't solve the problem on the other end.

Anyway, I'll try set_magic_quotes BEFORE the quote change & if that doesn't work, I'll try PHPmailer.

Thanks for your quick responses, as usual.
0
 

Author Comment

by:Richard Korts
ID: 17846135
To TeRRef,

I did set_magic_quotes_runtime(0) while the email body had data with ' in it. Still doesn't work.

I'll look at PHPmailer.

Thanks
0
 

Author Comment

by:Richard Korts
ID: 17846400
To TeRRef,

I tried this & it worked. It removed the "\" from the email body.

$body = stripslashes($body);
$mres = mail($mailto, $subj, $body, $header);

So your answer wasn't the full solution but I'm giving you the points because you are very knowledgable of php, you've helped me before & your comments led me to the solution.

Cheers!      
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17846599
Well done! Thanks for the points :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question