dingi Posted April 12, 2010 Share Posted April 12, 2010 I have a contact form that is processed by PHP and send email. The email php processor has the following code: $from_email = $_POST['field_2'];$headers = 'From: ' . $from_email . "\r\n". 'Reply-To:'.$from_email; mail("test@testmail.com", "Subject", "body of message"); All mails land up mostly in junk folder only. How do we make it to land up in Inbox. Please help to fix it. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/ Share on other sites More sharing options...
TeddyKiller Posted April 12, 2010 Share Posted April 12, 2010 I'll reply for subscription of this thread. I'd love to find out. Sometimes certain headers will allow certain mailers see it as safe. Sometimes otherwise... Sometimes you have to wait until the mailer checks it, and marks it as safe on their server. I don't know. Anywho. Hope you get the answer! Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040318 Share on other sites More sharing options...
JustLikeIcarus Posted April 12, 2010 Share Posted April 12, 2010 This is normally caused by the From: domain not matching the domain the email is actually being sent from. I usually have the issue if developing locally where the emails actually get sent from my laptop. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040336 Share on other sites More sharing options...
TeddyKiller Posted April 12, 2010 Share Posted April 12, 2010 My from domain is @horble.com, and the domain where it's being sent from (website address) is horble.com .. it still ends up in junk for many people. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040338 Share on other sites More sharing options...
JustLikeIcarus Posted April 12, 2010 Share Posted April 12, 2010 You need to post your code so we can take a look at how your sending. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040340 Share on other sites More sharing options...
PFMaBiSmAd Posted April 12, 2010 Share Posted April 12, 2010 The code you did post is NOT using the $header variable, which is probably for the best because you are putting the entered email address in as the From: address. The From: address must be a valid email address hosted at the sending mail server or there must be an SPF DNS record at the domain in the From: address that says that your mail server is authorized to send email for that domain. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040341 Share on other sites More sharing options...
TeddyKiller Posted April 12, 2010 Share Posted April 12, 2010 Whats an SPF DNS record? Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040348 Share on other sites More sharing options...
dingi Posted April 12, 2010 Author Share Posted April 12, 2010 This the PHP code that send mail: $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); session_start(); // FIELD VALIDATION . . . if( validEmail($e_mail) == true ) { // address ok } else { // address bad } if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) { $from_email = $_POST['field_3'];$headers = 'From: ' . $from_email . "\r\n". 'Reply-To:'.$from_email; if(isset($_POST['url']) && $_POST['url'] == '') if(isset($_POST['fax']) && $_POST['fax'] == '') // then send the form to your email mail("test@testmail.com","Form submission","Form data: Date: ".date('l dS \of F Y h:i:s A')." Form Submitted from User IP : " . $_POST['ip'] . " Name: " . $_POST['field_1'] . " Website URL: " . $_POST['field_2'] . " Email: " . $_POST['field_3'] . " Phone: " . $_POST['field_4'] . " Fax: " . $_POST['field_5'] . " Country: " . $_POST['field_6'] . " Place/City: " . $_POST['field_7'] . " Subject: " . $_POST['field_8'] . " Message: " . $_POST['field_9'] . " ","$headers"); header("Location:http://www.test.com/folder/thankyou"); exit(); } else { echo "Invalid Captcha String."; } Please Help. Thank you. How to incorporate SPF DNS in this form? Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040403 Share on other sites More sharing options...
premiso Posted April 12, 2010 Share Posted April 12, 2010 Whats an SPF DNS record? http://old.openspf.org/dns.html Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040408 Share on other sites More sharing options...
the182guy Posted April 12, 2010 Share Posted April 12, 2010 I always set the Return-Path header aswell as Reply-To. Also, some spam filters will check if the senders email address exists and can accept incoming mail. So it helps if your From email address, actually does exist. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040459 Share on other sites More sharing options...
dingi Posted April 13, 2010 Author Share Posted April 13, 2010 I always set the Return-Path header aswell as Reply-To. Also, some spam filters will check if the senders email address exists and can accept incoming mail. So it helps if your From email address, actually does exist. How to set Return-Path header in my above posted code? Can you just post the code here please? If using SMTP in the PHP will fix junk folder problem? If so, what SMTP Code must be inseted in the above form? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040745 Share on other sites More sharing options...
oni-kun Posted April 13, 2010 Share Posted April 13, 2010 $headers .= "Reply-To: foo@bar.com \n"; $headers .= "Return-Path: foo@bar.com \n"; Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040746 Share on other sites More sharing options...
dingi Posted April 13, 2010 Author Share Posted April 13, 2010 $headers .= "Reply-To: foo@bar.com \n"; $headers .= "Return-Path: foo@bar.com \n"; Thank you for giving the above code. Can we use SMTP in the contact form processor instead of normal mail to () function. If you could read the full mail processor code i mentioned above, you can easily help me insert SMTP. Please do the needful. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/198274-contact-form-mail-lands-up-only-in-spam-or-junk-folder-help/#findComment-1040747 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.