Zola Posted February 20, 2012 Share Posted February 20, 2012 Hi, I am having issues getting a simple contact form getting past the junk filter and into the inbox. Is there something wrong with my code? I have tried to set the email to 'not junk' in the 2 different email providers, but not change. Here is my code: <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Contact Form'; $to = '[email protected]'; $subject = 'Hello'; $human = $_POST['human']; $body = "From: $name\n E-Mail: $email\n Message:\n $message"; $headers .= "Content-type: text/plain; charset=utf-8\n"; $headers .= "From: website user<[email protected]> \n"; if ($_POST['submit']) { if ($name != '' && $email != '') { if ($human == '10') { if (mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; } } else { echo '<p>You need to fill in all required fields!!</p>'; } } ?> <form method="post" action="mail_.php"> <label>Name</label> <input name="name" placeholder="Type Here"> <label>Email</label> <input name="email" type="email" placeholder="Type Here"> <label>Message</label> <textarea name="message" placeholder="Type Here"></textarea> <label>*What is 7+3? (Anti-spam)</label> <input name="human" placeholder="Type Here"> <input id="submit" name="submit" type="submit" value="Submit"> </form> Any help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/257362-getting-a-simple-contact-form-past-spam-filter/ Share on other sites More sharing options...
psynor Posted February 20, 2012 Share Posted February 20, 2012 You should send it as multipart (html and plain text). A lot of filters marks emails as spam if they only contain one format Quote Link to comment https://forums.phpfreaks.com/topic/257362-getting-a-simple-contact-form-past-spam-filter/#findComment-1319154 Share on other sites More sharing options...
PFMaBiSmAd Posted February 20, 2012 Share Posted February 20, 2012 The 4th parameter in the mail function call would need to be the $headers variable, not the $from variable. Quote Link to comment https://forums.phpfreaks.com/topic/257362-getting-a-simple-contact-form-past-spam-filter/#findComment-1319156 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.