...

View Full Version : Trying to get the "from" field correct contact form sends. (2 images & actionscript)



Geruvah
05-11-2009, 11:05 PM
Hey guys, I'm hosting two sites. www.origamut.com and www.directignition.us, both use a contact form that uses PHP.

THE PROBLEM
When I send through origamut.com, the "from" correctly shows the e-mail of whatever is filled in the form. When I send through directignition.us, the "from" shows my host's mailserver's name to both the sender and the receiver, "pow.eggo@yourhostingaccount.com" (see attachments). In case you're wondering, the scripts on both are vastly different.

THE CODE THAT WORKS
Origamut.com has:

<?PHP

// read the variables form the string, (this is not needed with some servers).
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$message = $_REQUEST["message"];

$to = "eggo@eggo.us";
$subject = "E-mail From Contact Form";
$emailContent = "Name: " . $name;
$emailContent .= "\nEmail: " . $email;
$emailContent .= "\nMessage: " . $message;
$headers = "From: $email\n";
$headers .= "\nReply-To: $email";


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

echo "sentOk=" . $sentOk;

?>


THE CODE THAT NEEDS WORK
directignition.us uses xml and a phpscript (some of it is in spanish, as is the actionscript).
The xml says:

<mailForm buttonName= "Contact DI.us" forMeMail="eggo@eggo.us" forMeSubject="Sent from Direct Ignition's site" forUserSubject="Thanks for contacting us." forUserBody="Thanks for contacting Direct Ignition, we'll check your question and reply as soon as possible."></mailForm>

and the php for it says:

<?
// YOU DONT NEED TO CHANGE ANY OF THIS..... MAKE ALL CHANGES IN THE XML FILE ... MAKE CHANGES ON THIS ONLY IF YOU KNOW ABOUT PHP MAIL FORMS
$date = date("m/d/Y H:i:s");// TAKE THE HOUR FORM THE SERVER

// TAKE USER IP
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

//PROCESS THE INFORMATION AND SEND 2 MAILS ONE FOR YOU AND ONE FOR THE USER AS CONFIRMATION
if ($accion != ""):
mail("$Menvia","$Mtitulo",
" $Mtexto \n
Name: $nombre
Email: $email
Message: $mensaje

User Information :
------------------------------
plataform: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Hour: $date","OF:$Menvia");

//MAIL FO RTHE USER
mail("$email","$confirmT",
"Hello $nombre,\n
$confirmM!\n
Regards,
$Menvia
$Mtitulo","De:$Menvia");

//SEND A VARIABLE TO FLASH
Print "&enviado=1";
endif;

?>

My host said it's somewhere in the PHP to change this, just trying to figure out where.

THE ACTIONSCRIPT, IN CASE YOU NEED IT

// define some variables
falso.useHandCursor = false;
falso._visible = false;
Selection.setFocus("nombre");
accion = "enviar";
_parent.enviado = 0;
btn_enviar.onRelease = function() {
Menvia = _parent.forMeMail[0];//get some variables from the xml file
Mtitulo = _parent.forMeSubject[0];
Mtexto = "Message: ";// this is the default text for the mail you will send to yourself
confirmT = _parent.forUserSubject[0]
confirmM = _parent.forUserBody[0];
if (!email.length || email.indexOf("@") == -1 || email.indexOf(".") == -1) {// check the email
alerta.text = "e-mail incorrectly";
} else if (!nombre.length) {// check the name
alerta.text = "Please write your name";
} else if (!mensaje.length) {// check the comment
alerta.text = "Please write your message";
} else {
loadVariablesNum("contactForm.php", 0, "POST");// load the contactForm. php that must be in the same directory than your index
alerta.text = "Sending...";// message to the user
falso._visible = true;// cover the text boxes with a false button
btn_enviar._visible = false;// hide the send button

control.onEnterFrame = function() {
if (_parent.enviado == 1) {// this vairable will be received as 1 form the php file when the email has been sent
falso._visible = false;// hide te false button
btn_enviar._visible = true;// show the send btn
alerta.text = "Message Sent.";//change the message to user as sent
nombre = "";// clear the text boxes
email = "";
mensaje = "";
Selection.setFocus("nombre");// focus on name

delete control.onEnterFrame;// delete on enterframe function
}
};
}
};

stop();

venegal
05-11-2009, 11:28 PM
<?
// YOU DONT NEED TO CHANGE ANY OF THIS..... MAKE ALL CHANGES IN THE XML FILE ... MAKE CHANGES ON THIS ONLY IF YOU KNOW ABOUT PHP MAIL FORMS
$date = date("m/d/Y H:i:s");// TAKE THE HOUR FORM THE SERVER

// TAKE USER IP
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

//PROCESS THE INFORMATION AND SEND 2 MAILS ONE FOR YOU AND ONE FOR THE USER AS CONFIRMATION
if ($accion != ""):
mail("$Menvia","$Mtitulo",
" $Mtexto \n
Name: $nombre
Email: $email
Message: $mensaje

User Information :
------------------------------
plataform: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Hour: $date","OF:$Menvia");

//MAIL FO RTHE USER
mail("$email","$confirmT",
"Hello $nombre,\n
$confirmM!\n
Regards,
$Menvia
$Mtitulo","De:$Menvia");

//SEND A VARIABLE TO FLASH
Print "&enviado=1";
endif;

?>

I suppose "OF" and "De" in the header denote the sender. Try changing the red parts to $email and see what happens.

Geruvah
05-11-2009, 11:58 PM
That didn't make a difference, unfortunately.

venegal
05-12-2009, 01:05 AM
Then maybe try it with the good old english "From: $email" instead of "OF/De:$Menvia". It's what the other script does.

Geruvah
05-12-2009, 07:25 AM
Sadly, still nothing.

I changed it to:


<?
// YOU DONT NEED TO CHANGE ANY OF THIS..... MAKE ALL CHANGES IN THE XML FILE ... MAKE CHANGES ON THIS ONLY IF YOU KNOW ABOUT PHP MAIL FORMS
$date = date("m/d/Y H:i:s");// TAKE THE HOUR FORM THE SERVER

// TAKE USER IP
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

//PROCESS THE INFORMATION AND SEND 2 MAILS ONE FOR YOU AND ONE FOR THE USER AS CONFIRMATION
if ($accion != ""):
mail("$mail","$Mtitulo",
" $Mtexto \n
Name: $nombre
Email: $email
Message: $mensaje

User Information :
------------------------------
plataform: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Hour: $date","OF:$email");

//MAIL FO RTHE USER
mail("$email","$confirmT",
"Hello $nombre,\n
$confirmM!\n
Regards,
$Menvia
$Mtitulo","From: $email");

//SEND A VARIABLE TO FLASH
Print "&enviado=1";
endif;

?>

Would it have to do with what's written in the actionscript since we're doing something to Menvia?
btn_enviar.onRelease = function() {
Menvia = _parent.forMeMail[0];//get some variables from the xml file

Geruvah
05-15-2009, 03:36 AM
Sorry for bumping. I still need help with this.

Apostropartheid
06-03-2009, 09:53 PM
Try hardcoding $email as something and see whether it succeeds then?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum