help w/php mail

cscape01

New Member
Messages
7
Reaction score
0
Points
0
i have the PHP 5.2.5 - Intermediate Ver. i setup a php file to send an email but for some reason the php file is not sending the email to the recipient. please help this is whats in the php

<?php

//create short variable names
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$name=trim($name);
$email=trim($email);
$subject=StripSlashes($subject);
$message=StripSlashes($message);
//modify the next line with your own email address
$toaddress='tempmail@hotmail.com';


mail($toaddress,$subject,$message,"From: $name <$email>");
//clear the variables
$name='';
$email='';
$subject='';
$message='';
echo "response=passed";

?>

p.s. this is my first time using php so please help!
 
Last edited:

tittat

Active Member
Messages
2,478
Reaction score
1
Points
38
i cant find anything wrong.
Are you getting the message "response=passed" after running the script?
please post the complete code.......

post here the code of form page, from where you are intended to fill the details to send the mail.The problem might be there.
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
That code looks fine to me. I would double-check that the email you have in $toaddress is correct. Also, you might wanna blot it out if it is so spam bots can't get it.
 

konekt

New Member
Messages
100
Reaction score
0
Points
0
Here are some troubleshooting points from the API:

SUBJECT:

This must not contain any newline characters, or the mail may not be sent properly.

ADDITIONAL HEADERS:
Note: When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

Note: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.
 

cscape01

New Member
Messages
7
Reaction score
0
Points
0
okay i've been doing the form in flash mx 2004 so here is the coding for calling up the script

//presistant reference to this movie's mail timeline:
var mainTL:MovieClip = this;

//start off with submit button dimmed
submit_mc._alpha = 40;

//create the LoadVars objects which will be used later
//one to send the data...
var dataSender:LoadVars = new LoadVars();

//and one to recieve what comes back
var dataReceiver:LoadVars = new LoadVars();

/*
create listener for Key Object
this is just a U.I. thing - "wakes up" the submit button
when all fields have at least some content
*/

var formCheck:Object = new Object();
formCheck.onKeyUp = function() {
if (name_txt.text != '' &&
email_txt.text != '' &&
subject_txt.text != '' &&
message_txt.text != '') {
//clear any alert messages
alert_txt.text = '';
//enable the submit button
submit_mc._alpha = 100;
} else {
//remain disabled until all fields have content
submit_mc._alpha = 40;
}
}

Key.addListener(formCheck);

/*#######SET STYLES FOR TEXT FIELDS#######*/

//define styles for both normal and focussed
//set hex values here that work with your site's colors

var normal_border:Number = 0x7A7777;
var focus_border:Number = 0xFA8D00;

var normal_background:Number = 0xECECE6;
var focus_background:Number = 0xE9E3E3;

var normal_color:Number = 0x776D6C;
var focus_color:Number = 0x000000;

//create an array containing the fields we wish to have styles applied to

inputs=[name_txt,email_txt,subject_txt,message_txt];

/*
a "for in" loop now iterates through each element in the "inputs" array
and applies our "normal" formatting to each input text field
*/

for( var elem in inputs) {
inputs[elem].border = true;
inputs[elem].borderColor = normal_border;
inputs[elem].background = true;
inputs[elem].backgroundColor = normal_background;
inputs[elem].textColor = normal_color;
/*this takes care of applying the "normal" style to each of the four input fields;
the following TextField prototypes handle highlighting when an input field
gains focus and resetting to normal when a field loses focus*/
inputs[elem].onSetFocus = function() {
this.borderColor = focus_border;
this.backgroundColor = focus_background;
this.textColor = focus_color;
}
inputs[elem].onKillFocus = function() {
this.borderColor = normal_border;
this.backgroundColor = normal_background;
this.textColor = normal_color;
}
}

//finally: make the first field (name_txt) selected when the movie loads

Selection.setFocus(name_txt);

/*DEFINE SUBMIT BUTTON BEHAVIOR*/

submit_mc.onRelease = function() {
//final check to make sure fields are completed
if (name_txt.text != '' &&
email_txt.text != '' &&
subject_txt.text != '' &&
message_txt.text != '') {
alert_txt.text='';//clear any previous error messages or warnings
//advance playhead to frame 2 - the "processing" message
mainTL.play();
//assign properties to LoadVars object created previously
dataSender.name = name_txt.text;
dataSender.email = email_txt.text;
dataSender.subject = subject_txt.text;
dataSender.message = message_txt.text;
//callback function - how to handle what comes abck
dataReceiver.onLoad = function() {
if (this.response == "invalid") {
mainTL.gotoAndStop(1);
alert_txt.text = "Please check email address - does not appear valid."
} else if (this.response == "passed") {
mainTL.gotoAndStop(4);
}
}
//now send data to script
/*************************
NOTE: the line below presumes the Flash swf file and php script are in the
SAME DIRECTORY on your server. If this is not the case (if for example you
wish to put the php script along with other similar items in a "scripts"
directory) you MUST MODIFY THE PATH. Otherwise the Flash movie won't be
able to locate the php script.
*************************/
dataSender.sendAndLoad("processEmail.php", dataReceiver, "POST");
} else {
//warning if they try to submit before completing
alert_txt.text = "Please complete all fields before submitting form.";
}
}

p.s. also when the submit is clicked it says the it processing passed on the website, do i need a php.ini file??
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
It'll say that the processing passed even if it didn't since mail() doesn't throw a fatal error if it fails. In fact, it just returns false.

And you do already have a php.ini file, but since you're including the From header there's nothing to worry about there.

Anyway, again I don't see anything wrong. Try changing the echo part of your script to:

PHP:
//clear the variables
/*$name='';
$email='';
$subject='';
$message='';*/
$message = rawurlencode(utf8_encode($message));
echo "response=passed&name=$name&email=$email&subject=$subject&message=$message";

And then have the receiver object's load function display those other values to you. If any of them are blank or look incorrect, then the data must be getting mangled at some point.
 

cscape01

New Member
Messages
7
Reaction score
0
Points
0
And then have the receiver object's load function display those other values to you. If any of them are blank or look incorrect, then the data must be getting mangled at some point.

okay i did everything else but idon't get the part above
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
You would modify the function for dataReceiver.onLoad to something like this:

Code:
dataReceiver.onLoad = function() {
if (this.response == "invalid") {
mainTL.gotoAndStop(1);
alert_txt.text = "Please check email address - does not appear valid."
} else if (this.response == "passed") {
mainTL.gotoAndStop(1);
alert_txt.text = "Name: " + this.name + "\nEmail: " + this.email + "\nSubject: " + this.subject + "\nMessage: " + this.message;
}
}

That should display the values passed back from php.
 
Last edited:

cscape01

New Member
Messages
7
Reaction score
0
Points
0
so i put the new line to show me what is being sent and all that shows up is the name part
what am i gonna do i don't know how to build a different form in flash.
this took me a week to figure out the php way.

ahhhhhhh
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Only the name showed up? Well in that case, are you absolutely sure that the fields email_txt, subject_txt, and message_txt all exist?
 

cscape01

New Member
Messages
7
Reaction score
0
Points
0
yep all of them exist
each input text field has a property instance name of name_txt, email_txt,subject_txt,message_txt
Edit:
okay everything finally works!! woiwky and the rest of u have been really great thank u for such great hospitality!!
 
Last edited:
Top