Jump to content

Mail Form sends me my own AutoReply


Recommended Posts

Guest valleyglen
Posted (edited)

Hi there,

I am having trouble with the email form on my website. For some reason, when a user submits an email, I receive my own autoreply that I had set up with bluehost (my hosting provider). The autoreply is supposed to be sent to the user only, and I am supposed to only receive the email that the user sent. However, many times I will receive my autoreply but not the email from the user that should have triggered the autoreply in the first place. Does this make sense?

 

Through testing the email, I noticed that if I send an email directly to the address (without using the contact page form) it works properly. I get the email from the user, and only they get the autoreply. I also notice that the fields of the email are different when sent directly to the address. It's as though there are two separate codes going on for the email function.

 

The problem only occurs when I send an email using the form on my contact page. Can anyone please help me? I'm still a novice here, but I've been learning a lot since managing my own website. Here's the code associated with my contact.php page:

 

<?

session_start();

if($_REQUEST['action']=='submit'){

if($_REQUEST['name']=='')

{

$flag=1;

$error[]="Your Name was not entered.";

}

if($_REQUEST['email']=='')

{

$flag=1;

$error[]="Your email address was not given.";

}

if($_REQUEST['email']!='')

{

if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $_REQUEST['email'])) {

$flag=1;

$error[]="You must enter a valid email address.";

}

}

if($_REQUEST['verification']!=$_SESSION['security_code']){

$flag=1;

$error[]="Security image validation failed.";

}

if(count($error)==0){

$email=$_REQUEST['email'];

$sub="Request form for more information";

$headers= "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$headers .= "From: $email\r\n";

 

$name=$_REQUEST['name'];

$phone=$_REQUEST['phone'];

$comment=$_REQUEST['comment'];

$date=date('d/m/y h:i:s');

$remote=$_SERVER['REMOTE_ADDR'];

$msg="AskDougall has received an email from :-

 

 

 

Name : $name

 

 

 

Email: $email

 

 

 

Phone: $phone

 

 

 

Comment: $comment

 

 

 

Message recieved at $date from $remote

";

//-------------------you can change your email address here------------------

$email11="contact@myemailaddress.com";

//------------------------------------------------------------------------

mail($email11,$sub,$msg,$headers);

header("location: emailresponse.php");

}

}

?>

Any help would be greatly appreciated!

Edited by valleyglen
Posted

I'm trying to learn PHP myself and far from accomplished, but it looks like you should use $email not $email11 in your mail function. I'm not sure why you have ($email11="contact@myemailaddress.com";) in your code, so I may be way off. Good luck.

Posted

The reason you receive the auto-reply is due to the fact that you are emailing yourself form this page.

Add a section to the script which sends a "thank You for your email" reply to the user submitting the information.

Easy enough to do, just add another mail() using their address, or add a CC: header.

 

And stop the Auto-response at your mail client end, if you can adjust that using a whitelist/blacklist.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...