webshark360 Posted May 11, 2012 Share Posted May 11, 2012 I have a question regarding my email form submission. The email seems to work fine, but the recipient of the email can view my server information (see attached image for example) there are many website hosted on my server and i would like to hide the server info on form submissions. does anyone know of a way to do this? thanks Quote Link to comment https://forums.phpfreaks.com/topic/262428-help-php-form-showing-server-information-in-email/ Share on other sites More sharing options...
darkfreaks Posted May 12, 2012 Share Posted May 12, 2012 we need to see the code to figure out what is going on. thanks Quote Link to comment https://forums.phpfreaks.com/topic/262428-help-php-form-showing-server-information-in-email/#findComment-1344907 Share on other sites More sharing options...
.josh Posted May 12, 2012 Share Posted May 12, 2012 my first guess is that your email script isn't setting email headers properly (eg: the "From: ..." header). But what darkfreaks said. Quote Link to comment https://forums.phpfreaks.com/topic/262428-help-php-form-showing-server-information-in-email/#findComment-1344911 Share on other sites More sharing options...
webshark360 Posted May 14, 2012 Author Share Posted May 14, 2012 Here is the code for my form and send script what exactly is the problem? FORM CODE <head> <script type="text/javascript" language="javascript" src="js/validation_contact.js"></script> </head> <section id="enquiry_frm"> <form id="cform" name="cform" method="post" onsubmit="return ccheckform()" action="send_form.php"> <aside class="left"> <h2>Contact Us <span>Today</span></h2> <input type="text" value="Name" name="cname" id="cname" onFocus="if (this.value == 'Name') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Name';}" /> <input type="text" value="Email" name="cemail" id="cemail" onFocus="if (this.value == 'Email') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Email';}"/> <input type="text" value="Phone Number" name="cphone" id="cphone" onFocus="if (this.value == 'Phone Number') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Phone Number';}"/> </aside> <aside class="right"> <textarea rows="" cols="" name="cmessage" id="cmessage" onFocus="if (this.value == 'Message') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Message';}" >Message</textarea> <center><input type="submit" value=""/></center> </aside> </form> <img src="images/social_icons.png" alt="" style="float:right;margin-top:16px;"> <section class="clear"></section> </section> SEND FORM CODE <?php //$to = "[email protected]"; $to = "[email protected]"; $from= "Webshark360.com.com"; $subject="webshark360.com form has been submitted by $cname"; $cname=$_REQUEST['cname']; $cphone=$_REQUEST['cphone']; $cemail=$_REQUEST['cemail']; $cmessage= $_REQUEST['cmessage']; $SpamErrorMessage="No Websites URLs permitted"; if (preg_match("/http/i", "$cname")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$cphone")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$cemail")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$cmessage")) {echo "$SpamErrorMessage"; exit();} $message=" Name -$cname Phone-$cphone Email ID-$cemail Message-$cmessage"; $sent = mail($to, $subject, $message,$headers) ; if($sent) { header("location:thanks.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262428-help-php-form-showing-server-information-in-email/#findComment-1345357 Share on other sites More sharing options...
Jessica Posted May 14, 2012 Share Posted May 14, 2012 You never use your $from variable. Look at "Example #2 Sending mail with extra headers." in the docs mail as it shows you how to use headers to set the from address. Quote Link to comment https://forums.phpfreaks.com/topic/262428-help-php-form-showing-server-information-in-email/#findComment-1345374 Share on other sites More sharing options...
darkfreaks Posted May 14, 2012 Share Posted May 14, 2012 you can omit the $from variable and put it in your headers. $headers = 'From: Webshark360.com.com' . "\r\n" . 'Reply-To: Webshark360.com.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); alternately you can use phpmailer which uses SMTP email settings to achieve the same desired result. PHpmailer example: <?php require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.example.com"; // SMTP server $mail->From = "Webshark360.com.com"; //from your other adress $mail->AddAddress("[email protected]"); //sends the email to you $mail->Subject = "ebshark360.com form has been submitted by $cname"; $mail->Body = "Name -$cname Phone-$cphone Email ID-$cemail Message-$cmessage"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/262428-help-php-form-showing-server-information-in-email/#findComment-1345413 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.