Page 1 of 1

problem with contact form send mail function

Posted: Wed Sep 15, 2010 6:26 am
by gman1234
Hi
I have this form, when I want to send mail to myself with all the fields form the form, no matter what I do I can not get it to work. its ok sending reply email to the person tho. Area of problem highlighted in bold.

Please help
Gren

See code:

Code: Select all

// load the variables form address bar
include("my_message.php");
$name = $_POST["name"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$number = $_POST["number"];
$from = $_POST["from"];
$verif_box = $_POST["verif_box"];

// remove the backslashes that normally appears when entering " or '
$name = stripslashes(name);
$message = stripslashes($message); 
$subject = stripslashes($subject); 
$number= stripslashes ($number);
$from = stripslashes($from); 
//auto reply vars
//$replysub="the food galley";
$replymsg="Thanks for contacting the food galley, we will be intouch soon.\n\n the food gallery";
$email="grenambrose@gmail.com";
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
	// if verification code was correct send the message and show this page
[b]	mail("grenambrose@gmail.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");[/b]
	mail($from, 'the food galley',$mymessage, $headers);
	// delete the cookie so it cannot sent again by refreshing this page
	setcookie('tntcon','');
} else if(isset($message) and $message!=""){
	// if verification code was incorrect then return to contact page and show error
	header("Location: index.php?subject=$subject&from=$from&message=$message&wrong_code=true");
	exit;
} else {
	echo "no variables received, this page cannot be accessed directly";
	exit;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>E-Mail Sent</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
}
-->
</style></head>

<body>
Email sent. Thank you.
</body>
</html>

Re: problem with contact form send mail function

Posted: Wed Sep 15, 2010 1:15 pm
by Jonah Bron
What doesn't work? Do you get an error, or does the email just not send? Please surround your code with [syntax=php][/syntax] tags when posting code.

Re: problem with contact form send mail function

Posted: Wed Sep 15, 2010 5:26 pm
by gman1234
hi
when i add more variables ie $ number
to the first send mail, i dont receive any email, tho no errors come up and the thank you email is still sent.
why is this?

thanks for your help.

Re: problem with contact form send mail function

Posted: Wed Sep 15, 2010 5:44 pm
by Jonah Bron
You might try checking your spam box.

Re: problem with contact form send mail function

Posted: Wed Sep 15, 2010 5:57 pm
by gman1234
done that.
even if i take out the first mail and replace it with another, same issue, the first mail comand doesnt send. im lost to why

Re: problem with contact form send mail function

Posted: Wed Sep 15, 2010 7:12 pm
by agriz
Instead of this line

Code: Select all

mail("grenambrose@gmail.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
Did you try like this ?

Code: Select all

$f_headers  = 'MIME-Version: 1.0' . "\r\n";
$f_headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$f_headers .= 'From: Some User <$from>' . "\r\n";
mail("grenambrose@gmail.com", "Subject Test", "Message", $f_headers);

Re: problem with contact form send mail function

Posted: Wed Sep 15, 2010 8:48 pm
by Jonah Bron
Try just creating an empty PHP file, and put this into it:

Code: Select all

<?php
mail('grenambrose@gmail.com', 'subject line', 'this is a test email');
?>
See if you get the email. Also, please edit your original post to surround your code with the syntax tags (use the PHP Code button).