1

im working on a html form where i need to send mail using php. i need to upload it in my hosting server. i uploaded these two files in the root directory. still im not able to send mail. Here is my html code

<!-- form -->
<form  action="http://shankiyan.in/sendEmail.php"  method="post"  name="form" id="contactForm" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" >
    <fieldset>

        <div class="form-field">
            <input name="name" type="text" id="contactName" placeholder="Name" value="" minlength="2" required="">
        </div>
        <div class="form-field">
            <input name="email" type="email" id="contactEmail" placeholder="Email" value="" required="">
        </div>
        <div class="form-field">
            <input name="subject" type="text" id="contactSubject" placeholder="Subject" value="">
        </div>                       
        <div class="form-field">
            <textarea name="message" id="contactMessage" placeholder="message" rows="10" cols="50" required=""></textarea>
        </div>                      
        <div class="form-field">
            <button class="submitform"type="submit" name="submit" id="submitform">Submit</button>

        </fieldset>
</form>
<!-- Form End -->

and my php code is

<?php
require('sendEmail.php');
if(isset($_POST['submit'])){
    $name=$_POST['name'];
    $email=$_POST['email'];
    $formsubject=$_POST['subject'];
    $formmessage=$_POST['message'];


    $to="shmediyosel@gmail.com";
    $subject="subject:". $formsubject;
    $message="Name".$name."\n"."wrote the following".$formmessage;
    $headers="from".$email;

    if(mail($to,$subject,$message,$headers))
    {
        echo"<h1>message sent successfully</h1>";
    }
    else
    {
        echo"<h2> something went wrongg!</h2>";
    }


?>

i cant send mail from my html form . please help me out what mistake i have done ?

dhi_m
  • 1,235
  • 12
  • 21

1 Answers1

0

Try to put this code on the top of your php file and check for any errors:

error_reporting(E_ALL); ini_set('display_errors', 1);

Also, is the sendEmail.php requiring itself? Because this will not work.

If not, can you provide us with the sendEmail.php so we can understand easier the problem?

drkostas
  • 517
  • 1
  • 7
  • 29