Im doing an site and im having a problem in the contact part , I cant figure it out why its not sending emails, doesnt give me any errors but i do not receive the emails. My contact form recieves the data but doesnt send.
hope someone can help me with this.
Thank you.
My code is:
<form method="POST" action="contact.php" class="contact-form row">
<div class="inputs col-md-6 col-sm-6 col-xs-6">
<input type="text" id="name" name="name" placeholder="NAME">
</div>
<div class="inputs col-md-6 col-sm-6 col-xs-6">
<input type="email" id="email" name="email" placeholder="EMAIL">
</div>
<div class="inputs col-md-12 col-sm-12 col-xs-12">
<input type="text" id="subject" name="subject" placeholder="SUBJECT">
</div>
<div class="inputs col-md-12 col-sm-12 col-xs-12">
<label for="message">Message</label>
<textarea id="message" name="message" cols="50" rows="6" placeholder=""></textarea>
</div>
<div class="inputs contact-submit"><input type="submit" id="form-submit" value="ENVIAR MENSAGEM"></div>
</form>
PHP CODE:
<?php
if(isset($_POST['subject'], $_POST['email'], $_POST['name']))
{
$to = "(MY EMAIL)";
$from = $_POST['email'];
$name = $_POST['name'];
$headers = "From: $from";
$subject = $_POST['subject'];
error_reporting (E_ALL);
$fields = array();
$fields{"name"} = "name";
$fields{"email"} = "email";
$fields{"subject"} = "subject";
$fields{"message"} = "message";
$body = "Message From " . $name .":\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$send = mail($to, $subject, $body, $headers);
}
?>
Aucun commentaire:
Enregistrer un commentaire