May 18, 201115 yr Hi all, And yet again thanks for your help in advance. I've got a contact form that doesn't seem to work through an exchange server. It works fine when sending to an ordinary pop email account but when i change the recipients email address to the exchange one, it goes belly up. Is it something to do with the script or the spam settings on the server? The site is currently under development but just want a quick fix in the short term. The script is as follows <?php $visitor = $_POST['visitor']; $company = $_POST['company']; $telephone = $_POST['telephone']; $visitormail = $_POST['visitormail']; $enquiry = $_POST['enquiry']; $sendTo = ""; switch($_POST["branch"]) { case("bristol"): $sendTo = "paul.compton@electricwholesale.co.uk"; $branch = "Bristol"; break; case("london"): $sendTo = "paul.compton@electricwholesale.co.uk"; $branch = "London"; break; case("birmingham"): $branch = "Birmingham"; $sendTo = "paul.compton@electricwholesale.co.uk"; $branch = "Birmingham"; break; default: //<-- It executes the default if none of the above are true $sendTo = "paul.compton@electricwholesale.co.uk"; break; } ?> <!--- Content =--> <?php if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { include 'errorpage.php'; die; } if(empty($visitor) || empty($visitormail) || empty($enquiry) || empty($telephone) || empty($company)) { include 'errorpage.php'; die; } ?> <h2>Thanks for contacting us <?php echo $visitor ?>.</h2><h2>One of the Electric Wholesale team will be in touch soon</h2> <!--- /Content =--> <?php $todayis = date("l, F j, Y, g:i a") ; $subject = "Web Enquiry"; $enquiry = stripcslashes($enquiry); $message = " $todayis [GMT] \n From: $visitor ($visitormail)\n Branch: $sendTo ($branch)\n Company: $company \n Telephone: $telephone \n Enquiry: $enquiry \n "; $from = "From: $visitormail\r\n"; mail($sendTo, $subject, $message, $from); ?> The html is here <div class="form"><form method="POST" action="sendmail.php"> <h2>Branch</h2> <select size="1" name="branch"> <option value="bristol">Bristol - Head Office</option> <option value="london">London</option> <option value="birmingham">Birmingham</option> </select> <h2>Name</h2> <input type="text" name="visitor" size="28"> <h2>Company</h2> <input type="text" name="company" size="28"> <h2>Contact Tel</h2> <input type="text" name="telephone" size="28"> <h2>E-mail</h2> <input type="text" name="visitormail" size="28"> <h2>Enquiry</h2> <textarea name="enquiry" rows="9" cols="30"></textarea> <br><br /> <input type="submit" value="Submit" name="submit"> <input type="reset" value="Reset"> </form></div> Thanks again for your help OD
May 18, 201115 yr problem is if you mark it as from the users email but are sending it from a server who's not authorative for that domain then it looks like spam. Personally I'd try something like... $from = 'From: webmaster@electricwholesale.co.uk' . "\r\n" . 'Reply-To: '. $visitormail . "\r\n" . 'X-WebsiteContact: b0d745d6eaedb684c1a435a32a479780; Also you can get the exchange server admin to add a rule to the spam filter to always allow email with X-WebsiteContact header containing the string 'b0d745d6eaedb684c1a435a32a479780'. If both of those solutions dont work then send it via SMTP rather than through sendmail.
May 19, 201115 yr Author Thanks Jock, Ive tried your suggestions but alas it stilldoes not work. How do I set up SMTP sending? do i need to use PEAR MAIL PACKAGE or something? Thanks again OD
Create an account or sign in to comment