I'm setting up a website that has about 6 different HTML forms. I would like the data that people put into the form be sent to my gmail account. My web host is godaddy and I already had set up email forwarding with godaddy, but I haven't received them email when I uploaded the website files and tested the forms when the website was live.
I also changed the file extension from .html to .php to include the php code. However, in the end I didn't get an email. Additionally, I was reading about PHPMailer and Composer, but it seems all so complex, which shouldn't be if I set up email forwarding with godaddy for the gmail account.
NB: I'm extremely new to PHP
HTML Code:
<div class="container">
<div class="formBx">
<form>
<h2>Door to Door Inquiry</h2>
<div class="inputBox">
<input type="text" name="name" required="required">
<span>Full Name</span>
</div>
<div class="inputBox">
<input type="text" name="mail" required="required">
<span>Email Address</span>
</div>
<div class="inputBox">
<input type="text" name="phone" required="required">
<span>Phone Number</span>
</div>
<div class="inputBox">
<textarea type="text" name="message" required="required"></textarea>
<span>Type Your Message Here...</span>
</div>
<div class="inputBox">
<input type="submit" value="Send" name="">
</div>
</form>
</div>
<div class="imgBx">
<img src="images/door-door-delivery-service_82574-7443.jpg" alt="Picture of yellow, cartoon SUV.">
</div>
</div>
</section>
PHP Code:
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$to = "sitenameinfo@sitename.com";
$subject = "Site contact form";
$header = "From: ".$email."\r\n";
$header .= "Cc: ".$email."\n";
$header .= "Reply-To : ".$email."\r\n";
$header .= "Return-Path : ".$email."\r\n";
$header .= "X-Mailer: PHP\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
if(mail($to, $subject, $message, $header))
{
echo "Mail Sent Successfully";
}else{
echo "Mail Not Sent";
}
}
?>