mohaemdselim Posted March 21, 2011 Share Posted March 21, 2011 i have a page in my website with PHP , that do a customer comment and it send me an emails for those comments , and then send an automatic email to the customer , but my only problem is that i want the customer to receive the email as it is from the email i got my emails on , but when the customer received the email it received as my username in my host site @ hostsite.com i want to solve this please thanks. here is the code : <?php require_once('recaptchalib.php'); $errFlag=0; $showForm=1; //KEEP YOUR PRIVATE KEY HERE $privatekey = ""; // << replace this key with yours function isValidEmail($email){ return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL); } if (isset($_POST["submit"])){ $name=$_POST['name']; $lname=$_POST['lname']; $phone=$_POST['phone']; $email=$_POST['email']; $message=$_POST['message']; if(empty($_POST)) { $errMsg[]="Please enter all the field."; } if(empty($name)) { $errMsg[]="Please enter your First Name."; } if(empty($lname)) { $errMsg[]="Please enter your Last Name."; } if(empty($phone)) { $errMsg[]="Please enter phone number."; } elseif(!is_numeric($phone)) { $errMsg[]="Please enter valid phone number."; } if(empty($email)) { $errMsg[]="Please enter an email address."; } elseif(!isValidEmail($email)) { $errMsg[]="Please enter an valid email address."; } if(empty($message)) { $errMsg[]="Please enter message."; } /* captcha validation */ $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errMsg[]="The CAPTCHA wasn't entered correctly. Please try it again."; } if(empty($errMsg)) { // if there is no error then send a mail $ToEmail = 'myreiki11@gmail.com'; // CHANGE YOUR EMAIL WHERE YOU WANT TO RECEIVE THE CONTACT FORM SUBMITTED BY USERS... $EmailSubject = 'Customer Comments '; $mailheader = "From: ".$email."\r\n"; $mailheader .= "Reply-To: ".$email."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$name." ".$lname."<br>"; $MESSAGE_BODY .= "Phone: ".$phone."<br>"; $MESSAGE_BODY .= "Email: ".$email."<br>"; $MESSAGE_BODY .= "Comment: ".nl2br($message)."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); if(mail) { $msg="Thank your for submitting the form, we will contact your shortly."; $showForm=0; mail($email, "Thank your for submitting.", $msg); } else { $msg="Some errors occured, please try again in a while."; } } else { $errFlag=1; } } ?> <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="urn:schemas-microsoft-comfficeffice" xmlns="http://www.w3.org/TR/REC-html40"> <head> <link rel="shortcut icon" href="http://www.divineenergyhealing.co/favicon.ico"> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Customer Comments</title> <meta name="description" content="Customer Comments"> <link rel="File-List" href="reiki website/Reiki/Customer Comments_files/filelist.xml"> <base target="_self"> <!--[if !mso]> <style> v\:* { behavior: url(#default#VML) } o\:* { behavior: url(#default#VML) } .shape { behavior: url(#default#VML) } </style> <![endif]--><!--[if gte mso 9]> <xml><o:shapedefaults v:ext="edit" spidmax="1027"/> </xml><![endif]--> <style type="text/css"> /* error and success msg */ #errMsg { background-color:#febbbb; border:1px solid #d31a1c; color:#d31a1c; font-size:12px; padding:10px; margin-bottom:15px;} #successMsg { background-color:#ffffff; border:1px solid #ffffff; color:#000000; font-size:16px; padding:10px; margin-bottom:15px; margin-top:25px;} #contact_form { position: absolute; width: 888px; height: 365px; z-index: 1; left: 190px; top: 128px;} #contact_form form label { display:block;} contact_form p { margin-bottom:10px;} .auto-style1 { font-family: "Times New Roman", Times, serif; font-weight: bold; color: #FFFFFF; } </style> </head> <body link="#0000FF" vlink="#800000" alink="#FF0000"> <p> </p> <p align="left"> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p align="left"> </p> <div id="contact_form" style="left: 192px; top: 102px"> <?php if($errFlag) { echo "<div id='errMsg'>"; foreach($errMsg as $val) { echo "- "; echo $val; echo "<br />"; } echo "</div>"; } ?> <?php if($showForm){ ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="contact_form" method="post"> <p> <label for="name">First Name</label> <input name="name" type="text" id="name" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /> </p> <p style="height: 45px"> <label for="lname">Last Name</label><input name="lname" type="text" id="lname" style="width: 148px; height: 22px" value="<?php if (isset($_POST['lname'])) echo $_POST['lname']; ?>" /> </p> <p> <label for="phone">Phone Number</label> <input name="phone" type="text" id="phone" value="<?php if (isset($_POST['phone'])) echo $_POST['phone']; ?>" /> </p> <p> <label for="email">Email Address</label> <input name="email" type="text" id="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p> <p> <label for="message">Customer Comments</label> <textarea name="message" id="message" style="width: 247px; height: 84px" rows="999"><?php if (isset($_POST['message'])) echo $_POST['message']; ?></textarea> </p> <p> <?php //PUT YOUR PUBLIC KEY HERE $publickey = ""; // << replace this key echo recaptcha_get_html($publickey); ?> </p> <p><input name="submit" type="submit" value="Submit" /> <input name="reset" type="reset" value="Reset" /></p> </form> <?php } else { ?> <div id="successMsg" class="auto-style1">Thanks for your comments and questions we appreciate that you took the time to send us..</div> <?php }?> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.