mail is not getting to my inbox. while submit the form am getting message as mail has been sent, but after sending i checked my mail am getting mail in spam,how can i get the mail into inbox.

index.html

                <form method="post" name="sentMessage" action="mail/contact_me.php" id="contactfrm" role="form" enctype="multipart/form-data">

                    <div class="col-sm-4">
                        <div class="form-group">
                            <label for="name">Name</label>
                            <input type="text" class="form-control" name="name" id="name" placeholder="Enter name" title="Please enter your name (at least 2 characters)" required data-validation-required-message="Please enter your name.">
                            <p class="help-block text-danger"></p>
                            <p id="name-err" class="val-err"> </p>
                            </div>
                        <div class="form-group">
                            <label for="email">Email</label>
                            <input type="email" class="form-control" name="email" id="email" placeholder="Enter email" title="Please enter a valid email address" required data-validation-required-message="Please enter your email address.">
                                <p class="help-block text-danger"></p>
                            <p id="email-err" class="val-err"> </p>
                        </div>
                        <div class="form-group">
                            <label for="phone">Phone</label>
                            <input type="number" class="form-control" pattern="[0-9]{10}" name="phone" id="phone" placeholder="Enter Phone Number"  title="Please enter a valid Phone Number" maxlength="10" minlength="10" required data-validation-required-message="Please enter your phone number.">
                                <p class="help-block text-danger"></p>
                            <p id="phone-err" class="val-err"> </p>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label for="comments">Comments</label>
                            <textarea name="comment" class="form-control" id="comments" cols="3" rows="5" placeholder="Enter your messageā€¦" title="Please enter your message (at least 10 characters)" required></textarea>
                            <p id="comment-err" class="val-err"> </p>
                        </div>
                        <div class="clearfix"></div>
                        <div class="col-lg-12 text-center">
                            <div id="success"></div>
                            <button name="submit" type="submit"  id="submit" class="btn btn-lg btn-primary">Submit</button>
                        <div class="result" id="result"></div>
                        </div>
                    </div>
                </form>

mail/contact_me.php

<?php
// Check for empty fields

if(empty($_POST['name'])        ||
   empty($_POST['email'])       ||
   empty($_POST['phone'])       ||
   empty($_POST['comment']) ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
    echo "No arguments Provided!";
    return false;
   }

$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['comment'];

// Create the email and send the message

$from = 'joe@digitalvillage.in';
$mailcc = 'radha@digitalvillage.in';
$mailbcc = 'malathi@digitalvillage.in';
$email_subject = "Enquiry from digitalvillage.in";

function clean_string($string) {
                      $bad = array("content-type","bcc:","to:","cc:","href");
                      return str_replace($bad,"",$string);
                    }

$email_body = "You have received a new message from digitalvillage.in contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
//Phone: $phone\n\n
//$headers = "From: $from\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
//$headers .= "Reply-To: $email_address";
// create email headers
                $headers = 'From: '.$email_address."\r\n".
                'Reply-To: '.$from."\r\n" .
                'Cc: ' . $mailcc ."\r\n".
                'Bcc: ' . $mailbcc ."\r\n".
                'X-Mailer: PHP/' . phpversion();    



$retval = @mail('joe@digitalvillage.in',$email_subject,$email_body,$headers);

if($retval == true)
    {
    echo '<script>alert("Mail has been sent Successfully");
    window.location="../index.html#contactUs";</script>';

        }   


?>

Your script seems to be OK. Check your configuration (php.ini -> [mail function] section) which depends on your environment. In my Windows XAMP on localhost all mail is written to the C:\xampp\mailoutput directory (not really sent out).

got solved. if i will give valid name then only its coming to inbox, if i will give abcd@gmail.com means its considered as a spam user.

commented: Thnx for posting the solution +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.