mercredi 24 mars 2021

PHP code is working but not sending emails

I'm new to PHP and HTML working on a website both codes seem to be working. I'm trying to edit an existing contact us form and send the form to a default email.

Here is my HTML code part:

    <div class="row-fluid">
      <div class="span8" id="divMain">

        <h1>Contact Us</h1>
        <h3 style="color:#;"></h3>
        <hr>
        <!--Start Contact form -->                                                      
        <form name="enq" action="contact-form-handler.php" method="POST" onsubmit="return validation();">
          <fieldset>
            <input type="text" name="name" id="name" value=""  class="input-block-level" placeholder="Name" maxlength="80" />
            <input type="text" name="email" id="email" value="" class="input-block-level" placeholder="Email" maxlength="80" />
            <textarea rows="11" name="message" id="message" class="input-block-level" placeholder="Message" maxlength="1024"></textarea>        
            <div class="actions">
              <input type="submit" value="&nbsp;&nbsp;Send&nbsp;&nbsp;" name="submit" id="submitButton" class="btn btn-inverse pull-left" title="Click here to submit your message!" />
            </div>
          </fieldset>
        </form>                  
        <!--End Contact form -->                                             
      </div>

and here is my PHP code:

<?php
$name=$_POSt['name'];
$vistor_email=$_POST['email'];
$message=$_POST['message'];

$email_from='exp1@gmail.com';
$email_subject="New form submission";
$email_body="User Name:$name.\n"."User Email:$vistor_email.\n"."User message:$message.\n";

$to ='exp2@gmail.com';
$headers="From: $email_from\r\n";
$headers.="Reply to:$vistor_email \r\n";

mail($to,$email_subject,$email_body,$headers);
header("location: contact.html");
?>

I'm not getting any errors and I'm refreshing to the contact page again but still not receiving any emails from the form.




Aucun commentaire:

Enregistrer un commentaire