-1

I have a form where you fill out your subject and message then sends it to the email address that I provided. However when I submit I have a confirmation message indicating that the mail function returned true (mail was sent) but when I check my inbox no message is there. Here is my code:

<div class = "container">
    <div class = "row">
         <div class="col-xs-6">

        <form name = "contactform" action=" " method = "post" enctype="multipart/form-data" role="form">
        <div class="form-group">
        <input type="text" class="form-control"  name = "subject"placeholder = "Subject">
         </div>
         <div class="form-group">
     <textarea class="form-control" rows="5" name = "comments"placeholder = "Message"></textarea>
    </div>
        <div class="form-group">
        <input type="email" class="form-control" name = "email" placeholder = "Email address">
         </div>
         <div class="form-group">
        <input type="number" class="form-control" name = "telephone" placeholder = "Phone number">
         </div>

    <input type="submit" class="btn btn-default" value="Submit"/>
    <input type="hidden" name="button_pressed" value="1"/>

  <?php
    if(isset($_POST['button_pressed']))
    {
        $to = "marktester@hotmail.com";
        $subject = $_POST["subject"];
        $message = $_POST["comments"];
        $mailresult = mail($to, $subject, $message);
        if($mailresult ==true)
        {
            echo "message sent successfully";

        }
        else
        {
            echo "message did not send";

        }
        echo $to;
        echo $subject;
        echo $message;
    }
?>

What am I doing wrong here? Why is no email appearing in my inbox. Note: I am hosting the website on 000webhost.com with a .tk domain Thanks

CoreyK
  • 1
  • 2
  • There are several questions similar to this question asked on this website before. Try them first. – A J Jan 02 '16 at 06:41

2 Answers2

0

this might be issue with server.you can ask question to hosting guys.I suggest you to use http://swiftmailer.org/ with smtp authentication.will resolve your issue. see this Swiftmailer config : send mail using gmail

Community
  • 1
  • 1
0

As you are sending the email to a Hotmail account , Did you check your spam folder? This kind of free servers are usually marked as spam by most email providers. Another test you can do is to send the email to one of the emails you can create at 000webhost so you can do all the test internally.

Lastly as other suggested , you could also use SMTP to send your emails, but that´s out of the question itself.

Yeikel
  • 854
  • 10
  • 18