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('[email protected]', $_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 ) 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('[email protected]', $_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('[email protected]', $_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... 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> 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. 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. Link to comment https://forums.phpfreaks.com/topic/67105-solved-send-mail/#findComment-337249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.