cyfer65 Posted November 17, 2009 Share Posted November 17, 2009 I have a working PHP mail sending script, the only problem is that when i try to send any kinda symbol in Either the Message Title or the Message body it messes up the text..Like if i wanted to put quotes in the title or embed a picture into the message body with <img src='pic.jpg' /> it gets all messed up..!!is there any specific way to make it so I can include these symbols so the message don't get ruined..?? <?php$to=$_POST["to"];$from=$_POST["from"];$name=$_POST["name"];$subject=$_POST["subject"];$message=$_POST["message"];$headers = "From: \"$name\" <$from>\nContent-Type: text/html; charset=iso-8859-1";$ret=mail("$to", "$subject", "$message", "$headers");if($ret==true)echo"Mail sent Successfully";elseecho"Unable to Send mail";?> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 17, 2009 Share Posted November 17, 2009 What do you mean it gets messed up, what does it do? Link to comment Share on other sites More sharing options...
cyfer65 Posted November 18, 2009 Author Share Posted November 18, 2009 like if i put something in "Quotes" it will do this to it on the recipients mail \"Quotes\" or if i try to embed a picture in the message body with <img src='http://pic.jpg' /> it removes parts of the embed string on the recipients email..??is there something missing or wrong in my PHP code that would be doing this..?? Link to comment Share on other sites More sharing options...
Ingolme Posted November 18, 2009 Share Posted November 18, 2009 The quotes problem happens because of PHP's "Magic Quotes". It's a system that automatically adds quotes to input strings so that scripts made by amateur developers don't allow the database to be hacked.You can determine if Magic Quotes are on by using the get_magic_quotes_gpc() function and then remove them using stripslashes(). Link to comment Share on other sites More sharing options...
cyfer65 Posted November 18, 2009 Author Share Posted November 18, 2009 sounds kinda complicated,would you mind showing me an example of how to implement that into my PHP mail sending code..??And what about the problem with trying to embed a picture into the message body with <img src="http://pic.jpg" />..?? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 18, 2009 Share Posted November 18, 2009 $name = get_magic_quotes_gpc() ? stripslashes($_POST['name']) : $_POST['name'];Use that on anything coming from $_POST, $_GET, or $_COOKIE. Link to comment Share on other sites More sharing options...
Synook Posted November 19, 2009 Share Posted November 19, 2009 Or, if possible, just disable magic_quotes completely. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.