Jump to content

Contact form Mail lands-up only in spam or junk folder Help


Recommended Posts

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.

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!

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.

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.

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?

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.

$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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.