0

For some reason, i am not receiving any mails...

Heres the form :

<form action="send.php" method="POST">
            <div class="cdiv">
                <label for="name">Name</label>
                <input class="floatlabel info" id="name" type="text" placeholder="Enter Name" required />

            </div>
            <div class="cdiv">
                <label for="email">Email</label>
                <input class="info" type="email" id="email" placeholder="Enter Your Email ID" required />
            </div>
            <div class="cdiv" style="height:75px;">
                <label for="msg">Message</label>
                <textarea class="info" id="msg" rows="3" placeholder="Enter Your Message" required></textarea>
            </div>
            <button type="submit" id="sendbtn">SEND</button>
        </form>

Heres the send.php

<?php
 $name = $_POST['name'];
 $email = $_POST['email'];
 $message = $_POST['message'];
 $to = "myemail@gmail.com";
 $subject = "webmessage";
 $body = "Automated Message: \nName : $name \nEmail : $email\n\nMessage :   \n$message";
mail($to,$subject,$body);
echo "Message Sent!";
?>

Please tell me what is wrong with this code and why it is not sending the email. In the real code, myemail is replaced with the actual email id. Everytime I send an email to myself and check my inbox, there is no email there.

programmingandroid
  • 340
  • 1
  • 5
  • 14
  • 1
    Have you [configured PHP correctly](http://php.net/manual/en/mail.configuration.php)? Or are you expecting `mail` to magically work? – Elias Van Ootegem Nov 20 '15 at 17:49
  • problem could be in my web hosting - awardspace. Do you know of any free web hosting that allows mail()? – programmingandroid Nov 20 '15 at 17:49
  • 2
    You are not sending a `from` field in the header, and gmail autorejects mail without the `from` field in the header. Furthermore, you should use a library such as `SwiftMailer` or the `PhpMailClass` that will help you in making sure you have well formed mail. – Ohgodwhy Nov 20 '15 at 17:50

0 Answers0