need help with a mail function mystery

Whenever my form is processed, I get two emails. The first one is sent from my server with a from address like [email protected]. Anyone have a clue why I’m getting this first email? I’d very much like it to go away! Here is the php…

<?php session_start(); if(isset($_POST['add'])){ if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. $dbhost = 'p50mysql39.secureserver.net'; $dbuser = 'coupon4u'; $dbpass = 'DC%000a'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } if(! get_magic_quotes_gpc() ) { $fname = addslashes ($_POST['box1']); $lname = addslashes ($_POST['box2']); } else { $fname = $_POST['box1']; $lname = $_POST['box2']; } if ($fname == NULL) {print 'ERROR!
Required field left blank
We are sorry but please hit your browsers back button and fill out all required form fields before submitting. Thank You.'; exit; } if ($lname == NULL) {print 'ERROR!
Required field left blank
We are sorry but please hit your browsers back button and fill out all required form fields before submitting. Thank You.'; exit; } $email = $_POST['box3']; if ($email == NULL) {print 'ERROR!
Required field left blank
We are sorry but please hit your browsers back button and fill out all required form fields before submitting. Thank You.'; exit; } function check_email_address($email) { if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { return false; } $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true;} if (check_email_address($email)) { echo NULL;} else { echo 'ERROR!
Email Address not valid.
We are sorry but your Email address is incorrect
please return to the previous page and double check your Email address, Thank You.'; exit; } $sql = "INSERT INTO test ". "(fname,lname,email) ". "VALUES('$fname','$lname','$email')"; mysql_select_db('coupon4u'); $retval = mysql_query( $sql, $conn ); mysql_close($conn); if($retval){ $thankyou = "Your coupon has been emailed, thank you!"; }else{ die('Could not enter data: ' . mysql_error().'

Please return to the"coupon request form"'); } } else { // Insert your code for showing an error message here echo '
Sorry, you have provided an invalid security code. Please try again.
'; } } $to = "[email protected]"; $subject = "Coupon Request"; $fname = $_REQUEST['box1']; $lname = $_REQUEST['box2']; $email = $_REQUEST['box3']; $message = "
Customer Name: $fname $lname  
Email: $email  
"; $headers = "Content-type: text/html; charset=iso-8859-1rn" . "\r\n" . "From: $email"; mail("$to","$subject","$message","$headers"); ?>

is your server free ? have u tried to run this script on another server ? maybe it is because of server …

Godaddy is the host, never had this problem before. I think it’s an error in the scrit somewhere.

In your headers…put the From before the Content-Type and try again.

Thanks for the help, looks like I figured it out. The curly bracket just above $to should have been at the end of the script. (shaking my head in disbelief :o)

Sponsor our Newsletter | Privacy Policy | Terms of Service