E-A-S-Y question php syntax with mail
Moderator: General Moderators
E-A-S-Y question php syntax with mail
Newbie's PHP server script question:
Assuming the balance of this PHP server script code (not shown) is correct why won't this mail to the address provided in the variable 'email' ???
$sendTo = $_POST["email"];
mail($sendTo, $subject, $message, $headers);
Thanks in advance.
Assuming the balance of this PHP server script code (not shown) is correct why won't this mail to the address provided in the variable 'email' ???
$sendTo = $_POST["email"];
mail($sendTo, $subject, $message, $headers);
Thanks in advance.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Addendum to above question...
Code: Select all
<?php
$sendTo = $_POST["email"];
$subject = "*** Instant Email Response ***";
$headers = "From: " . $_POST["email"] ." "."<" . $_POST["email"] .">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-path: " . $_POST["email"];
$message = $_POST["email"] ;
mail($sendTo, $subject, $message, $headers);
?>PHENOM | PLEASE READ POSTING GUIDLINES
This code worked until I changed this...
$sendTo = "myemailaddress@snet.netl";
to this...
$sendTo = $_POST["email"];
...in an effort to send the email to the address stated in the variable 'email' that gets sent to this server script.
$sendTo = "myemailaddress@snet.netl";
to this...
$sendTo = $_POST["email"];
...in an effort to send the email to the address stated in the variable 'email' that gets sent to this server script.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Run this code before your mail function. It will show you what is in your $_POST array:
Code: Select all
<?php
echo '<HR><PRE>'; print_r($_POST); echo '</PRE>';
?>- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
echo $_POST['email'];
//or
print_r($_POST); //to see all your form valuesput that at the top of your script.. is it what you are expecting?
nice 1 hawleyjr
Just to reiterate...
The code works tried and tested - EXCEPT - when I change that one line from a simple "myemailaddress@snet.net" to this whole $_POST["email"] thing...
...the variable 'email' IS a valid email address and is transmiting to the script (as proven when I substitute a plain old email address in quotes for the $_POST["email"] thing...
Thanks
The code works tried and tested - EXCEPT - when I change that one line from a simple "myemailaddress@snet.net" to this whole $_POST["email"] thing...
...the variable 'email' IS a valid email address and is transmiting to the script (as proven when I substitute a plain old email address in quotes for the $_POST["email"] thing...
Thanks
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Tried the ol' print_r($_POST); technique... nothing.
Let me give a quick background...
Web site is Flash swf file that sends variable 'email' to the server script provided in this post.
The swf and php files DO WORK, and reliably do their job ONLY if the $sendTo is defined as a simple email like...
myemailaddress@snet.net
Now I'd like to modify the php script to send an email not to myemailaddress@snet.net, but rather to an email address sent to the php script from the flash swf in the form of variable "email"
Maybe this isn't as simple as swapping the static email address for a variable sent to the php server side script ???
Thanks for any input.
Let me give a quick background...
Web site is Flash swf file that sends variable 'email' to the server script provided in this post.
The swf and php files DO WORK, and reliably do their job ONLY if the $sendTo is defined as a simple email like...
myemailaddress@snet.net
Now I'd like to modify the php script to send an email not to myemailaddress@snet.net, but rather to an email address sent to the php script from the flash swf in the form of variable "email"
Maybe this isn't as simple as swapping the static email address for a variable sent to the php server side script ???
Thanks for any input.