Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,898 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,718 people online right now. Registration is fast and FREE... Join Now!




send Mail Script

 
Reply to this topicStart new topic

send Mail Script, Small script used for flash

bmcc81
17 Mar, 2008 - 05:52 PM
Post #1

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
Hi,

Can anyone tell me why this isn't working on my server?
Thanks,

CODE
<?php

$to = "brandonmccarthy@hotmail.com";
$subject = "Flash Contact Form Submission";
$message = "Name: " . $theName;
$message .= "\nEmail: " . $theEmail;
$message .= "\n\nMessage: " . $theMessage:
$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail";

$sentOk = mail($to,$subject,$message,$headers);

echo "sentOk" . $sentOk;

?>



Attached File(s)
Attached File  send.php ( 360bytes ) Number of downloads: 24
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Send Mail Script
17 Mar, 2008 - 06:13 PM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,267



Thanked: 14 times
Dream Kudos: 650
My Contributions
What's being echoed as the value of $sentOk?
User is online!Profile CardPM
+Quote Post

bmcc81
RE: Send Mail Script
17 Mar, 2008 - 06:19 PM
Post #3

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
CODE

echo "sentOk" . $sentOk;

echo "sentOk=" . $sentOk;

User is offlineProfile CardPM
+Quote Post

_net
RE: Send Mail Script
17 Mar, 2008 - 06:24 PM
Post #4

D.I.C Head
**

Joined: 22 Sep, 2007
Posts: 146


My Contributions
Whats your error message?

and take a look at this line:
$message .= "\n\nMessage: " . $theMessage:

semi-colon problem.

Also, I would use something along the lines:

php


if ($sentOk = mail($to,$subject,$message,$headers)) {
echo "Message Sent";
} else {
echo "Message Failed to Send";
}




This post has been edited by _net: 17 Mar, 2008 - 06:28 PM
User is offlineProfile CardPM
+Quote Post

andrewvw
RE: Send Mail Script
17 Mar, 2008 - 06:30 PM
Post #5

New D.I.C Head
Group Icon

Joined: 27 Jan, 2008
Posts: 28


Dream Kudos: 50
My Contributions
this is what i use u can fix it a little
instead of going to a new page it does it all on the same one

CODE

<?


if(sizeof($_POST)) {

$body = $_REQUEST['Messafe'];
$subject =$_REQUEST ['Subject'];
while(list($key, $val) = each($HTTP_POST_VARS)) {

$body .= "$key: $val \n";

}



mail("example@example.com", //were the message will be sent

"$subject", // obviously the subject

$body); // and the message



echo "Thank You.";

}





?>



<form method=post action=<? echo $PHP_SELF; ?>>
Subject:
<input type="text" name="Subject" ><br>
Message
<input type="text" name="Message">
<input type="submit">
</form>


might have messed up on something correct me if im wrong
what i do is use the subject area for the person to put their email address in


This post has been edited by andrewvw: 18 Mar, 2008 - 05:45 PM
User is offlineProfile CardPM
+Quote Post

bmcc81
RE: Send Mail Script
18 Mar, 2008 - 02:42 PM
Post #6

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
Thanks,

I appreciate the help. But I know I need to cange the " From ' field of my scrip to my email address.

Would it be

FROM THIS:

CODE
$headers = "From: $theEmail";


TO THIS:

CODE
$headers = "From: myemailaddress@hotmail.com";

User is offlineProfile CardPM
+Quote Post

bmcc81
RE: Send Mail Script
18 Mar, 2008 - 02:58 PM
Post #7

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
I just tried the code
CODE
<?php

$to = "someemail@hotmail.com";
$subject = "Flash Contact Form Submission";
$message = "Name: " . $theName;
$message .= "\nEmail: " . $theEmail;
$message .= "\n\nMessage: " . $theMessage;
$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail";

$sentOk = mail($to,$subject,$message,$headers);

echo "sentOk=" . $sentOk;

?>


And it worked except that all I got was:

The subject and

Name:

Email:

Message:

What do you think is the problem?

This post has been edited by bmcc81: 18 Mar, 2008 - 04:24 PM
User is offlineProfile CardPM
+Quote Post

bmcc81
RE: Send Mail Script
18 Mar, 2008 - 03:49 PM
Post #8

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
I think I need to make a superglobal

I have toto figure out whether I'm parsing it to PHP as either a GET or POST request, and whichever one it is it's parsing the information to, I need to call on that superglobal array to retrieve the information in PHP. The superglobal arrays are $_GET[] and $_POST[] respectively.

But how do I add that into my code? I've never worked with PHP much.
Thanks for the help.
User is offlineProfile CardPM
+Quote Post

thehat
RE: Send Mail Script
18 Mar, 2008 - 03:53 PM
Post #9

D.I.C Head
Group Icon

Joined: 28 Feb, 2008
Posts: 217


Dream Kudos: 100
My Contributions
This is coming from Flash, right? By default the sendAndLoad function of Flash uses post.

php

<?php

$to = "brandonmccarthy@hotmail.com";
$subject = "Flash Contact Form Submission";
$message = "Name: " . $_POST['theName'];
$message .= "\nEmail: " . $_POST['theEmail'];
$message .= "\n\nMessage: " . $_POST['theMessage'];
$headers = "From: $_POST['theEmail']";
$headers .= "\nReply-To: $_POST['theEmail']";

$sentOk = mail($to,$subject,$message,$headers);

echo "sentOk=" . $sentOk;

?>


This post has been edited by thehat: 18 Mar, 2008 - 03:53 PM
User is offlineProfile CardPM
+Quote Post

bmcc81
RE: Send Mail Script
19 Mar, 2008 - 08:40 AM
Post #10

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
This didn't work when I put it online.
What else could be the problem?
User is offlineProfile CardPM
+Quote Post

bmcc81
RE: Send Mail Script
19 Mar, 2008 - 08:56 AM
Post #11

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
I got this weird error, when I go online and get the address I get,

CODE
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/alternc/html/d/davidgirard/mail/send.php on line 8


I'm not really sure what it means, but maybe those are setting I need to add to my send.php?
User is offlineProfile CardPM
+Quote Post

thehat
RE: Send Mail Script
19 Mar, 2008 - 09:04 AM
Post #12

D.I.C Head
Group Icon

Joined: 28 Feb, 2008
Posts: 217


Dream Kudos: 100
My Contributions
Ah, sorry, you can't put arrays into a string like I did, you have to concatenate. Try this:

php

1. <?php
2.
3. $to = "brandonmccarthy@hotmail.com";
4. $subject = "Flash Contact Form Submission";
5. $message = "Name: " . $_POST['theName'];
6. $message .= "\nEmail: " . $_POST['theEmail'];
7. $message .= "\n\nMessage: " . $_POST['theMessage'];
8. $headers = "From: " . $_POST['theEmail'];
9. $headers .= "\nReply-To: " . $_POST['theEmail'];
10.
11. $sentOk = mail($to,$subject,$message,$headers);
12.
13. echo "sentOk=" . $sentOk;
14.
15. ?>

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 09:30PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month