Formularz nie działa, robiony na przykładzie z neta. Proszę o pomoc.
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "...";
$email_subject = "Kontakt z ...";
function died($error) {
// your error code can go here
echo "Niestety napotkano problemy podczas wysyłania. ";
echo "Dokładniej:<br /><br />";
echo $error."<br /><br />";
echo "Aby wysłać, należy poprawić błędy.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['mail']) ||
!isset($_POST['subject']) ||
!isset($_POST['message'])) {
died('Formularz nie został poprawnie wypełniony.');
}
$first_name = $_POST['name']; // required
$email_from = $_POST['mail']; // required
$subject = $_POST['subject']; // not required
$message = $_POST['message']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'Niepoprawny adres email.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'Niepoprawne imię.<br />';
}
if(strlen($message) < 2) {
$error_message .= 'Za krótka wiadomość.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Szczegóły wiadomości.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($first_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Subject: ".clean_string($subject)."\n";
$email_message .= "Message: ".clean_string($message)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Dziękuję za kontakt. Odpowiem jak najszybciej.
<?php
}
?>
Interesuje mnie ostatnich kilka linijek. Błędu nie ma, maila nie wysyła.