May 13, 201214 yr Any idea why the mail sent from this contact form going in spam folder? <?php //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['contactname']) == '') { $hasError = true; } else { $name = trim($_POST['contactname']); } //Check to make sure that the subject field is not empty if(trim($_POST['subject']) == '') { $hasError = true; } else { $subject = trim($_POST['subject']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) == '') { $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'neophytech007@gmail.com'; //Put your own email address here $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments"; $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> <head> <title>Contact Us</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="" /> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> <script src="js/jquery.validate.pack.js" type="text/javascript"></script> <script type="text/javascript" src="js/jquery.cycle.all.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#contactform").validate(); }); </script> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="css/ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="css/ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="css/ie8.css"> <![endif]--> <script type="text/javascript"> $.fn.cycle.defaults.timeout = 6000; $(function() { // run the code in the markup! $('table pre code').not('#skip,#skip2').each(function() { eval($(this).text()); }); $('ul.slide').before('<div id="nav">').cycle({ fx: 'fade', speed: 'fast', timeout: 3000, next: 'ul.slide', pager: '#nav' }); }); </script> <script type="text/javascript"> Cufon.replace('span.fet_name'); </script> <script type="text/javascript"> $(document).ready(function(){ $('#slider1').tinycarousel(); }); </script> </head> <body> <div id="top-header"> <div class="container"> <h1 class="logo"> <a href="index.html"></a></h1> <div class="top_head_rght"> <div class="some_wish"><ul class="wish"> <li class="phone">Call Us :800.544.7985</li> <li><a href="" class="twitter"> </a></li> <li><a href="" class="facebook"> </a></li> </ul></div><!--some--> <ul class="topnav"> <li class=" nobg"><a href="index.html">Home</a></li> <li><a href="firm_overview.html"> Firm Overview</a></li> <li><a href="accident_faq.html">Accident FAQ </a></li> <li ><a href="testimonials.html"> Testimonials </a></li> <li><a href=" verdicts_settlements.html"> Verdicts & Settlements </a></li> <li><a class="select" href=" contact_us.html"> Contact Us</a></li> </ul> <div class="clear"></div> </div><!--top_head_rght--> </div><!--container--> </div><!--top-header--> <div class="content_sub"> <div class="container"> <div class="con_lft"> <div class="one_third_sub"> <h2>TESTIMONIALS</h2> <img src="images/com.png" alt="slide" class="com_img"/> <p>Maecenas ac purus lacus. Morbi in dictum nibh. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sed felis massa. Suspendisse imperdiet nulla a elit congue faucibus. Cras placerat blandit cursus...</p> <p class="test_auth">John Smith</p> <div class="clear"></div> <img src="images/com.png" alt="slide" class="com_img"/> <p>Maecenas ac purus lacus. Morbi in dictum nibh. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sed felis massa. Suspendisse imperdiet nulla a elit congue faucibus. Cras placerat blandit cursus...</p> <p class="test_auth">John Smith</p> <div class="clear"></div> <a href="" class="more"> Read more »</a> </div><!--one_third--> <div class="clear"></div> <div class="one_third"> <h2>PAST CASES</h2> <img src="images/hom_img2.png" alt="slide" class="hom_img"/> <p>Maecenas ac purus lacus. Morbi in dictum nibh. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sed felis massa. Suspendisse imperdiet nulla a elit congue faucibus. Cras placerat blandit cursus...</p> <a href="" class="more"> Read more »</a> </div><!--one_third--> </div><!--con_lft--> <div class="con_rght"> <h2>CONTACT US</h2> <div id="contact-wrapper"> <?php if(isset($hasError)) { //If errors are found ?> <p class="error">Please check if you've filled all the fields with valid information. Thank you.</p> <?php } ?> <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <p><strong>Email Successfully Sent!</strong></p> <p>Thank you <strong><?php echo $name;?></strong> for using my contact form! Your email was successfully sent and I will be in touch with you soon.</p> <?php } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform"> <div> <label for="name"><strong>Name:</strong></label> <input type="text" size="50" name="contactname" id="contactname" value="" /> </div> <div> <label for="email"><strong>Email:</strong></label> <input type="text" size="50" name="email" id="email" value="" /> </div> <div> <label for="subject"><strong>Subject:</strong></label> <input type="text" size="50" name="subject" id="subject" value="" /> </div> <div> <label for="message"><strong>Message:</strong></label> <textarea rows="5" cols="50" name="message" id="message"></textarea> </div> <input type="submit" value="Send Message" name="submit" /> </form> </div> </div><!--con_rght--> <div class="clear"></div> <div class="con_low"> <h2>O & M CONTACT</h2> <p>Phone: 123-456-7890<br/> Fax: 123-456-7890<br/> Address: 123 St. 456 Rd.<br/> City, State, Zip<br/> Email: info@mail.com</p> </div><!--con_low--> <div class="con_txt"> <h2>SERVING YOU</h2> <p>From offices in Los Angeles and San Bernardino, California, the Girardi | Keese law firm represents clients throughout California and nationwide. Our primary service area includes Los Angeles, San Bernardino, Long Beach, Anaheim, Glendale, Beverly Hills, Burbank, Pasadena, Santa Ana, Riverside, Santa Clarita, Irvine, San Diego, Sacramento, Bakersfield, San Francisco, San Jose, Berkley, Oakland and other communities in Los Angeles County, San Bernardino County, Riverside County, Orange County, San Mateo County, San Diego County, Sacramento County, Alameda County, Santa Clara County and San Francisco County. </p> </div><!--con_txt--> <div class="clear"></div> </div><!--container--> </div><!--content_sub--> <div id="footer"> <div class="container"> <div class="foo_left"> <ul class="foo_lower"> <li><a href="index.html" class="first">Home</a></li> <li><a href="firm_overview.html"> Firm Overview</a></li> <li><a href="accident_faq.html">Accident FAQ </a></li> <li><a href="testimonials.html">Testimonials</a></li> <li><a href=" contact_us.html">Contact Us</a></li> </ul> </div><!--foo_left--> <div class="foo_rght"> <p class="copy">Copyright ©O and M llc.com .All Rights Reserved </p> </div><!--foo_rght--> <div class="clear"></div> </div><!--container--> </div><!--footer--> </body> </html>
May 13, 201214 yr $emailTo = 'neophytech007@gmail.com'; //Put your own email address here $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments"; $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; Gmail is almost certainly having a hissy fit over the headers. It knows that the email was not sent from the same gmail account recieving it Try this.. $headers = 'From: My Site <contact123@mysite.com>' . "\r\n" . 'Reply-To: ' . $email
May 13, 201214 yr Author tried ur code it gives parse error? Parse error: syntax error, unexpected T_STRING in /home/webdesi1/public_html/law/contact_us.php on line 45
May 13, 201214 yr Author thanks i got it sorted someone helped me $to = 'neophytech007@gmail.com'; $subject = "$name Contact you from www.example.com ."; $message = "Contact Name : $name \n Contact Email : $email \n\n Message : $comments"; $from = $email; $headers = "From:" . $email; mail($to,$subject,$message,$headers); $emailSent = true;
Create an account or sign in to comment