Jump to content

[SOLVED] send mail...


SirDuke

Recommended Posts

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 :P)

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.