contact form not sending emails

Discussion in 'PHP' started by john.smith892, Sep 18, 2013.

  1. #1
    Hello all,
    This is my first thread in this forum, I hope you could help me in this thread.

    I've created a contact form for my website, I'm using php, html and css
    php is used for the contact form engine that sends the mail,

    Here is my code:

    HTML:

    <div id="sss">
    <form method="post" action="contactengine.php">
    <input type="text" id="name">
    <input type="text" id="emailad">
    <textarea name="message" id="message" cols="30" rows="10">
    <input type="submit" class="send" value="Send" />
    </form>
    </div>
    </div>

    PHP:

    <?php
    $EmailTo = "My email";
    $Subject = "Message Sent";
    $Name = Trim(stripslashes($_POST['Name']));
    $Email = Trim(stripslashes($_POST['Email']));
    $Message = Trim(stripslashes($_POST['Message']));
    // validation
    $validationOK=true;
    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    exit;
    }
    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";
    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    // redirect to success page
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.html\">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>

    the contact thanks page is displayed by no email received

    Thanks all
     
    john.smith892, Sep 18, 2013 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    You're missing a name-property on your two text inputs.
     
    PoPSiCLe, Sep 18, 2013 IP
  3. RogueCZzzz

    RogueCZzzz Greenhorn

    Messages:
    9
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #3
    <form method="post" action="contactengine.php">
    <input name="Name" type="text" id="name">
    <input name="Email" type="text" id="emailad">
    <textarea name="Message" id="message" cols="30" rows="10">
    <input type="submit" class="send" value="Send" />
    </form> 
    Code (markup):
     
    RogueCZzzz, Sep 18, 2013 IP
  4. xxxize

    xxxize Member

    Messages:
    33
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    38
    #4
    Maybe is php configuration problem in php.ini
    Locate php.ini and check SMTP values (values for your mail server):
    SMTP = your mail server e.g) mail.yourdomain.com
    smtp_port =25(check your admin for original port)
     
    xxxize, Sep 18, 2013 IP
  5. john.smith892

    john.smith892 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    It was the name property, message arrived finally .. Thank you all !!
     
    john.smith892, Sep 18, 2013 IP