0

// This is html file

<form role="form" action="mail.php" method="post">

      <div class="form-group">
        <input type="text" class="form-control" id="name" name="name" placeholder="Name" required>
       </div>

       <div class="form-group">
         <input type="text" class="form-control" id="email" name="email" placeholder="Email" required>
       </div>

       <div class="form-group">
         <input type="text" class="form-control" id="mobile" name="mobile" placeholder="Contact No." required>
       </div>

       <div class="form-group">
           <textarea name="comment" class="form-control" type="textarea" id="message" placeholder="Comment on services required" rows="7"></textarea>     
     </div>

       <button type="submit" id="submit" name="submit" class="btn btn-primary">Submit Mail
       </button>

          </form>

// This is php file attached to above html file

// I didn't get the mail after the submission of this code.

    <?php
    if (isset($_POST['submit']))
    {
        $sender_name=stripslashes($_POST["name"]);
        $sender_email=stripslashes($_POST["email"]);
        $sender_mobile=stripslashes($_POST["mobile"]);
        $sender_message=stripslashes($_POST["comment"]);

        $subject = "Enquiry Form";

        $body  = " \n";
        $body .= " Name : ".$sender_name."\n";
        $body .= " Email : ".$sender_email."\n";
        $body .= " Mobile : ".$sender_mobile."\n";
        $body .= " Brief : ".$sender_message."\n";


        $to = "shubham.tropicalcluster@gmail.com";

        if(mail($to, $subject, $body, "From: $sender_email")) {
           header('Location:thanks.html');
        }    
    }

    else {
        echo "ERROR SHUBHAM";
    }
    ?>

//can I get a code that works my all form means universal .php file to mail all the details in the html form

Shubham
  • 11
  • 1

1 Answers1

0

Please add following script in file mail.php. (Rename it something custommail.php). You can check that your server will send email or not.

<?php
// the message
$msg = "First line of text\nSecond line of text";

// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);

// send email
mail("shubham.tropicalcluster@gmail.com","My subject",$msg);
?>
Vasim Shaikh
  • 4,485
  • 2
  • 23
  • 52