0

I want little help. My contact form works fine , but why are my emails going into recipients' spam folders? Thank you in advance!

Here is my code:

<?php

$to = 'my_email@myhost.bg';


$date=date("l, F jS, Y");
$time=date("h:i A");

$subject=$_REQUEST['contact-subject'];
$type=$_REQUEST['type'];
$name=$_REQUEST['contact-name']; 
$email=$_REQUEST['contact-email']; 
$message=$_REQUEST['contact-messege'];

I guess its something wrong here, because the information about sender is too little

$msg  = "";
$msg .= "Message sent from ZEUS website on date:  $date, hour: $time.\n";
$msg .= "Sender name: $name\n";
$msg .= "Subject: $subject\n";
$msg .= "Sender Email: $email\n";
$msg .= "Sender Message: $message\n";

if($type == 'footer-newsletter') {
    //Validate form from footer
    if($_REQUEST['foot-news-email']=="") {
        echo "<div class='alert alert-danger'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Warning!</strong> Please fill the Email field.
        </div>";
    } else {
        mail($to,$subject,$msg,"From:".$email);
        echo "<div class='alert alert-success'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Thank you!</strong>
        </div>";
    }

} else if($type == 'sidebar-newsletter') {
    //Validate form from footer
    if($_REQUEST['suscribe-email']=="") {
        echo "<div class='alert alert-danger'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Warning!</strong> Please fill the Email field.
        </div>";
    } else {
        mail($to,$subject,$msg,"From:".$email);
        echo "<div class='alert alert-success'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Thank you!</strong>
        </div>";
    }

} else if($type == 'contact') {
    //Validate form from footer
    if($_REQUEST['contact-name']=="") {
        echo "<div class='alert alert-danger'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Warning!</strong> Please fill the Name field.
        </div>";
    } else  if($_REQUEST['contact-email']=="") {
        echo "<div class='alert alert-danger'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Warning!</strong> Please fill the Email field.
        </div>";
    } else {
        mail($to,$subject,$msg,"From:".$email);
        echo "<div class='alert alert-success'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Thank you!</strong>
        </div>";
    }

} else if($type == 'comments') {
    //Validate form from footer
    if($_REQUEST['comments-name']=="") {
        echo "<div class='alert alert-danger'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Warning!</strong> Please fill the Name field.
        </div>";
    } else  if($_REQUEST['comments-email']=="") {
        echo "<div class='alert alert-danger'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Warning!</strong> Please fill the Email field.
        </div>";
    } else {
        mail($to,$subject,$msg,"From:".$email);
        echo "<div class='alert alert-success'>
            <a class='close' data-dismiss='alert'>×</a>
            <strong>Thank you!</strong>
        </div>";
    }

}

?>
  • Allright, but I learn php from 2 months, and i'm not sure that i will understand their answers if they are for advanced people in that language. I just wanted to answer me if the problem is very small, but never mind, i'll keep trying – Stanislav Bozhilov Feb 12 '16 at 21:59
  • There's nothing too advanced about the other question: basically you must set the "from" email address the same domain as the mail function is being called from. – Terry Feb 12 '16 at 22:02
  • So, @Terry when you said it that way it helps me a lot! Thank you very much! – Stanislav Bozhilov Feb 12 '16 at 22:04

0 Answers0