0

I want to send emails without using any database that's why I was trying to send an email using PHP and HTML, but the problem is that after pressing the submit button it does not sending any emails. Here are my codes:

<form role="form" name="contactform" id="contactform" method="POST" action="send.php" enctype="multipart/form-data">
    <div class="row">
       <div class="col-md-6">
            <div class="input-text form-group">
                     <input type="text" name="contact_name" class="input-name form-control" placeholder="Full Name" />
                                    </div>
                                    <div class="input-text form-group">
                                    <input type="email" name="email" class="input-name form-control" placeholder="Enter Email-ID" />
                                    </div>
                                    <div class="input-text form-group">
                                        <input type="text" name="contact_phone" class="input-name form-control" placeholder="Phone Number" />
                                    </div>
                                </div>
                                <div class="col-md-6">

                                    <div class="input-text form-group">
                                        <input type="text" name="contact_sub" class="input-name form-control" placeholder="Subject" />
                                    </div>
                                    <div class="textarea-message form-group">
                                        <textarea name="contact_message" class="textarea-message hight-82 form-control" placeholder="Message" rows="2"></textarea>
                                    </div>
                                </div>
                                <div class="col-md-12">

                                   <input type="submit" class="btn btn-default top-margin-10 hblack" name="Submit" value="Submit" />
                                </div>
                            </div>
                        </form>

and the PHP code are:

<?php

$strTo = $_POST["contact_name"];
$strSubject = $_POST["email"];
$strMessage = nl2br($_POST["contact_phone"]);
$strSub = nl2br($_POST["contact_sub"]);
$strmsg = nl2br($_POST["contact_message"]);

$body="Job-title:$title \r\n
Name:$strTo \r\n
Email:$strSubject \r\n
Phone:$strMessage \r\n
Subject:$strSub \r\n
Message:$strmsg";
$from=$strSubject;

$to='abc@abc.com'; // removed for spam protection

mail($to,$from,$body);

echo "<script> alert('Your Form has been Submitted successfully'); window.location.href='index.php'; </script>";

?>

Thanks in advance.

1 Answers1

0

If you use the mail function then you will have to make some server side changes to your php settings. Most commonly these changes are found in a file called "php.ini". I encourage looking up changes needed for the mail function to work on your specific server and including details about your server and php version when searching