Simple email form keeps sending email to spam folder

Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same.
This is the link to my form.
http://www.people.eurico.co.uk/

here my form script

<?php

// Set email variables
$email_to = 'xxxxx@xxxxxxx.co.uk';
$email_subject = 'Call back form';

// Set required fields
$required_fields = array('fullname','email','telephone','comment');

// set error messages
$error_messages = array(
	'fullname' => 'Please enter a Name to proceed.',
	'email' => 'Please enter a valid Email.',
	'telephone' => 'Please telephone.',
	'comment' => 'Please enter your Message to continue.'
);

// Set form status
$form_complete = FALSE;

// configure validation array
$validation = array();

// check form submittal
if(!empty($_POST)) {
	// Sanitise POST array
	foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
	
	// Loop into required fields and make sure they match our needs
	foreach($required_fields as $field) {		
		// the field has been submitted?
		if(!array_key_exists($field, $_POST)) array_push($validation, $field);
		
		// check there is information in the field?
		if($_POST[$field] == '') array_push($validation, $field);
		
		// validate the email address supplied
		if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
	}
	
	// basic validation result
	if(count($validation) == 0) {
		// Prepare our content string
		$email_content = 'peoplesmartlearning.co.uk: ' . "\
\
";
		
		// simple email content
		foreach($_POST as $key => $value) {
			if($key != 'submit') $email_content .= $key . ': ' . $value . "\
";
		}
		
		// if validation passed ok then send the email
		mail($email_to, $email_subject, $email_content);
		
		// Update form switch
		$form_complete = TRUE;
	}
}

function validate_email_address($email = FALSE) {
	return (preg_match('/^[^@\\s]+@([-a-z0-9]+\\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}

function remove_email_injection($field = FALSE) {
   return (str_ireplace(array("\\r", "\
", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}

?>

The HTML

<div class="call_us_form">
        		<p class="title">WE'LL CALL YOU BACK</p>
				<?php if($form_complete === FALSE): ?>
				<form class="contact_form" id="fm-form" method="post" action="index.php" >
                <fieldset>
                    <div class="fm-req">
                        <label for="fm-firstname">Name</label>
 <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" />
<?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?>
                    </div>

                    <div class="fm-req">
                    <label for="fm-firstname">Email</label>
                 <input type="text" id="email" class="detail" name="email" value="
			<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" />
			<?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?>
                    </div>

					<div class="fm-req">
                    <label for="fm-firstname">Number</label>
 <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" />
 	<?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?>
                    </div>
					
                    <div class="fm-req">
                        <label for="fm-lastname">Message</label>
<textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea>
			<?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?>
                    </div>
                <input class="submit_button" type="submit" value="Call us" />
                </fieldset>
            </form>
<?php else: ?>
<p>Thank you for your Message!</p>
<p>We will get back to you as soon as we can</p>

<script type="text/javascript">
	setTimeout ('ourRedirect()', 5000)
	function ourRedirect () {
		location.href='index.php'
		}
</script>
<?php endif; ?>

A few things you could try would be:

  • a different subject
  • a fifth parameter in the mail() function. E.g.
mail($email_to, $email_subject, $message, null, [COLOR="#FF0000"]'-fwebmaster@example.co.uk'[/COLOR]);

That last one is an email address from the same domain as your site. You haven’t actually shown us your mail() function.

Hi the top part is my email function thats all i use to send the email, do you think because i am not using email from my host/website it spam the email that comes from that host. I mean is my site is eurico.co.uk so I have to use the name@eurico.co.uk to receive emails from and I am not allowed to use any other email like an hotmail email thats why it goes to my spam??

Sorry, I missed the

mail($email_to, $email_subject, $email_content);

line in there, so thought your code was incomplete.

do you think because i am not using email from my host/website it spam the email that comes from that host.

No, not really. But you should try those suggestions I made. Change your subject, and try changing

mail($email_to, $email_subject, $email_content);

to

mail($email_to, $email_subject, $email_content, null, '-[COLOR="#FF0000"]name[/COLOR]@eurico.co.uk');

Of course, change name to whatever your real email name is.

Since this is your own email folder that the message is addressed to, can you not simply change your spam settings? You should be able to whitelist the user(s) who are sending you the messages.

Mike

Hi thanks eevryone for the help. unfortunnaly still not working I tried whitelist the contact didnt work I aslo tried to change the setting ralph.m told and it doesnt even send the email nomore.
Any other suggestions are greattly appreciated. Please.

Are yo sure that it is only this particular email that is going to spam? Have you tried manually sending an email from another address, just to see if it goes through OK? That would tell you if the fault lies in the way the email is being sent, or whether it’s something more generally wrong with your email system.

Mike

Hi yes that is the only email that goes to my spam folder is the one that comes from that contact form this is the whole script you can just copy and paste change the add the email you wish to go to and you will notice it will send it to your own span folder.

<?php

// Set email variables
$email_to = 'xxxx@xxxxxx.co.uk'; // add your email here
$email_subject = 'Form submission';

// Set required fields
$required_fields = array('fullname','email','telephone','comment');

// set error messages
$error_messages = array(
	'fullname' => 'Please enter a Name to proceed.',
	'email' => 'Please enter a valid Email.',
	'telephone' => 'Please telephone.',
	'comment' => 'Please enter your Message to continue.'
);

// Set Email Headers
$headers = 	'From: you Website <noreply@xxxxx.co.uk>' . "\\r\
" .
			'X-Mailer: PHP/' . phpversion() . "\\r\
";
$headers  .= 'MIME-Version: 1.0' . "\\r\
";
$headers .= 'Content-type: text/html; charset=iso-8859-1';

// Set form status
$form_complete = FALSE;

// configure validation array
$validation = array();

// check form submittal
if(!empty($_POST)) {
	// Sanitise POST array
	foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
	
	// Loop into required fields and make sure they match our needs
	foreach($required_fields as $field) {		
		// the field has been submitted?
		if(!array_key_exists($field, $_POST)) array_push($validation, $field);
		
		// check there is information in the field?
		if($_POST[$field] == '') array_push($validation, $field);
		
		// validate the email address supplied
		if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
	}
	
	// basic validation result
	if(count($validation) == 0) {
		// Prepare our content string
		$email_content = 'xxxxxx.co.uk: ' . "\
\
";
		
		// simple email content
		foreach($_POST as $key => $value) {
			if($key != 'submit') $email_content .= $key . ': ' . $value . "\
";
		}
		
		// if validation passed ok then send the email
		mail($email_to, $email_subject, $email_content, $headers);
		
		// Update form switch
		$form_complete = TRUE;
	}
}

function validate_email_address($email = FALSE) {
	return (preg_match('/^[^@\\s]+@([-a-z0-9]+\\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}

function remove_email_injection($field = FALSE) {
   return (str_ireplace(array("\\r", "\
", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}

?>


    <div id="content"><!--start content-->
   		<section> <!--START OF SLIDE SHOW-->
    	<div id="slide_show">

			<div class="call_us_form">
        		<p class="title">WE'LL CALL YOU BACK</p>
				<?php if($form_complete === FALSE): ?>
				<form class="contact_form" id="fm-form" method="post" action="index.php" >
                <fieldset>
                    <div class="fm-req">
                        <label for="fm-firstname">Name</label>
 <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" />
<?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?>
                    </div>

                    <div class="fm-req">
                    <label for="fm-firstname">Email</label>
                 <input type="text" id="email" class="detail" name="email" value="
			<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" />
			<?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?>
                    </div>

					<div class="fm-req">
                    <label for="fm-firstname">Number</label>
 <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" />
 	<?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?>
                    </div>
					
                    <div class="fm-req">
                        <label for="fm-lastname">Message</label>
<textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea>
			<?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?>
                    </div>
                <input class="submit_button" type="submit" value="Call us" />
                </fieldset>
            </form>
<?php else: ?>
<p>Thank you for your Message!</p>
<p>We will get back to you as soon as we can</p>

<script type="text/javascript">
	setTimeout ('ourRedirect()', 5000)
	function ourRedirect () {
		location.href='index.php'
		}
</script>
<?php endif; ?>
        </div>



        			<div class="clear"></div>
		

For the proper functioning of my emails I availed the help of urgentechelp.com. The expertise team of urgentechelp.com possesses sound knowledge on all email related queries and issues. Their services are available at a low cost. The best aspect about urgentechelp.com is that they make a courtesy call after 15 days to check that whether all is fine