SirDuke Posted August 28, 2007 Share Posted August 28, 2007 does anyone see what's wrong here? This little piece of code won't work. I'm calling it through a Flex application but it doesnt seem to work anway... :-\ <?php $Body = "Name: ".$_POST["fullname"]."\n"; $Body .= "Email: ".$_POST["email"]."\n"; $Body .= "Phone: ".$_POST["phone"]."\n"; $Body .= "Message: ".$_POST["text"]; $Return ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n"; $Return .= "<message>\r\n"; if (mail('mymail@gmail.com', $_POST["subject"], $Body) { Return .= "<text>Message successfully sent</text>\r\n"; } else { Return .= "<text>Message delivery failed...</text>\r\n"; } $Return .= "</message>"; print ($Return); ?> (also, what does that "\r" do anyway? I use it cause i saw it somewhere ) Quote Link to comment https://forums.phpfreaks.com/topic/67105-solved-send-mail/ Share on other sites More sharing options...
php_tom Posted August 28, 2007 Share Posted August 28, 2007 Yeah, \r is a carriage 'R'eturn (same thing [pretty much] as a 'N'ewline: \n). In windows filesystems, a new line is \r\n In Mac its \r in *nix its \n Confusing isnt it? We need some standards here... The problem with you code could be if (mail('mymail@gmail.com', $_POST["subject"], $Body) { Return .= "<text>Message successfully sent</text>\r\n"; } else { Return .= "<text>Message delivery failed...</text>\r\n"; } what you probably mean is if (mail('mymail@gmail.com', $_POST["subject"], $Body) { $Return .= "<text>Message successfully sent</text>\r\n"; } else { $Return .= "<text>Message delivery failed...</text>\r\n"; } Try that, post back if it still doesn't work... Quote Link to comment https://forums.phpfreaks.com/topic/67105-solved-send-mail/#findComment-336551 Share on other sites More sharing options...
SirDuke Posted August 29, 2007 Author Share Posted August 29, 2007 oh that was stupid i fixed that error but it still doesn't work. I debug from Flex to see what i get back from Apache and my message.text variable is null. I also get a "parse error" returned which makes me think this script has some kind of other error in it... Any insight? btw, what i expect to get back to Flex is: <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <message> <text> Message delivery failed... </text> </message> Quote Link to comment https://forums.phpfreaks.com/topic/67105-solved-send-mail/#findComment-337121 Share on other sites More sharing options...
SirDuke Posted August 29, 2007 Author Share Posted August 29, 2007 i found the error... my if was missing a second closing parenthesis ")" It works fine now, thanx By the way doesn't Dreamweaver check PHP syntax? Cause this was clearly a syntax error. Quote Link to comment https://forums.phpfreaks.com/topic/67105-solved-send-mail/#findComment-337161 Share on other sites More sharing options...
php_tom Posted August 29, 2007 Share Posted August 29, 2007 dunno about dw. i use SciTE (Scientific Text Editor) it has syntax highliting for PHP. Quote Link to comment https://forums.phpfreaks.com/topic/67105-solved-send-mail/#findComment-337249 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.