-1

My contact form doesn't send messages.

There are no errors reported in validation so i get the "message sent", but message is not actually sent. So propably there is an error on configuring my mail settings

Here is my code:

HTML:

<div class="container">
    <div class="row">
        <div class="col-lg-12 text-center">
            <h2 class="section-heading middle_heading">Contact Us</h2>
            <div class="colored-line2"></div>
            <p class="populer_des"></p>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <form class="bg_field" name="sentMessage" action="./mail/validateform.php" method="post" id="contactForm" novalidate>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="Your Name *" id="name" required data-validation-required-message="Please enter your name.">
                            <p class="help-block text-danger"></p>
                        </div>
                        <div class="form-group">
                            <input type="email" class="form-control" placeholder="Your Email *" id="email" required data-validation-required-message="Please enter your email address.">
                            <p class="help-block text-danger"></p>
                        </div>
                        <div class="form-group">
                            <input type="tel" class="form-control" placeholder="Your Phone *" id="phone" required data-validation-required-message="Please enter your phone number.">
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <textarea class="form-control" placeholder="Your Message *" id="message" required data-validation-required-message="Please enter a message."></textarea>
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="col-lg-12 text-center">
                        <div id="success"></div>
                        <button type="submit" class="btn btn-xl submit_message">Send Message</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

PHP:

if(empty($_POST['name'])        ||
    empty($_POST['email'])      ||
    empty($_POST['phone'])      ||
    empty($_POST['message'])    ||
    !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['message'];

    $to = 'mail.ornithas.gr'; 
    $email_subject = "Website Contact Form:  $name";
    $email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail:       $email_address\n\nPhone: $phone\n\nMessage:\n$message";
    $headers = "From:mail.ornithas.gr\n"; 
    $headers .= "Reply-To: $email_address"; 
    mail($to,$email_subject,$email_body,$headers);
    return true; 
Community
  • 1
  • 1
DopeAt
  • 451
  • 3
  • 15

3 Answers3

0

Header should be separated by '\r\n' not '\n' so header variable should be

$headers = "From: masudcsep@gmail.com\r\n";
$headers .= "Reply-To: $email_address";

Nabil
  • 355
  • 1
  • 4
  • 11
0

check your $to email address... it looks incorrect. So mail sending fail.

Jignesh Patel
  • 1,028
  • 6
  • 10
-1
  1. Check if the URL that you entered is correct:

    <form class="bg_field" name="sentMessage" action="./mail/validateform.php" method="post" id="contactForm" novalidate>
    

    this: ./mail/validateform.php means that you have a folder mail in your current directory which further has a file called: validateform.php .

  2. check the filename

  3. check the code in the file.

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
  • Thank you bro.... I have the mail folder back so i should type ../mail/validateform.php instead of ./mail/validateform.php.... – DopeAt May 20 '16 at 12:05