My contact form does not send emails here is my code:
HTML:
<div class="col-md-6">
<form id="fcf-form-id" class="fcf-form-class" method="post" action="php/form-control.php">
<div class="row">
<div class="form-group col-md-6">
<label for="Name">Twoje imię</label>
<input type="Name" class="form-control" id="Name">
</div>
<div class="form-group col-md-6">
<label for="Email">Twój telefon</label>
<input type="Email" class="form-control" id="Email">
</div>
</div>
<div class="form-group">
<label for="Message">Wiadomość</label>
<textarea type="Message" class="form-control" id="Message" rows="3"></textarea>
</div>
<button type="submit" class="btn font-weight-bold atlas-cta atlas-cta-wide cta-green my-3">Wyślij</button>
</form>
</div>
PHP:
<?php
if (isset($_POST['Email'])) {
// EDIT THE FOLLOWING TWO LINES:
$email_to = "...@gmail.com";
$email_subject = "Automedyk - Wiadomość z formularza";
function problem($error)
{
echo "Przykro nam ale wystąpił błąd. ";
echo "<br><br>";
echo $error . "<br><br>";
echo "Prosimy o powrót i poprawę błędów.<br><br>";
die();
}
// validation expected data exists
if (
!isset($_POST['Name']) ||
!isset($_POST['Email']) ||
!isset($_POST['Message'])
) {
problem('Przykro nam ale wystąpił błąd.');
}
$name = $_POST['Name']; // required
$email = $_POST['Email']; // required
$message = $_POST['Message']; // required
$error_message = "";
$email_exp = "/^[A-Za-z .'-]+$/";
if (!preg_match($email_exp, $email)) {
$error_message .= 'Nieprawidłowy adres email.<br>';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if (!preg_match($string_exp, $name)) {
$error_message .= 'Nieprawidłowe imię.<br>';
}
if (strlen($message) < 2) {
$error_message .= 'Nieprawidłowa treść wiadomości.<br>';
}
if (strlen($error_message) > 0) {
problem($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message .= "Name: " . clean_string($name) . "\n";
$email_message .= "Email: " . clean_string($email) . "\n";
$email_message .= "Message: " . clean_string($message) . "\n";
// create email headers
$headers = 'From: ' . $email . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- INCLUDE YOUR SUCCESS MESSAGE BELOW -->
Dziękujemy za wiadomość, skontaktujemy się niebawem!
<?php
}
?>
Have no idea how to fix it and start sending messages to my email