mam formularz kontakowy w php odpowiedzialny za wysyłanie maila ze strony. Coś w nim nie działa: mianowicie po uzupełnieniu wszystkich pól formularza wysyła informację "wiadomość nie została wysłana. Spróuj ponownie". Wszystkie pola formularza są wypałnione poprawnie.
Ktoś mógłby podpowiedzieć, gdzie jest błąd w kodzie?
Załaczam kod php
<?php // Your email address $to = 'moj.mail@mail.pl'; $subject = $_POST['subject'];; // Don't edit below unless you know what you're doing if($to) { $name = $_POST['name']; $email = $_POST['email']; 'text' => 'Name', 'val' => $_POST['name'] ), 'text' => 'Email address', 'val' => $_POST['email'] ), 'text' => 'Message', 'val' => $_POST['message'] ) ); $message = ""; foreach($fields as $field) { } /* $header.="Mime-Version: 1.0rn"; $header.="Content-type: text/html; charset=UTF-8"; $header.="Content-Transfer-Encoding: 8bitrn"; $subject=iconv("UTF-8","ISO-8859-2", $subject); $subject='=?UTF-8?B?'.base64_encode($subject).'?='; $headers .= "From: \"" . $name . "\" \r\n"; $headers .= "Reply-To: " . $email . "\r\n"; $message = utf8_decode($message); */ $naglowki = "Reply-to: ".$email."<".$email.">".PHP_EOL; $naglowki .= "From: <".$name.">".PHP_EOL; $naglowki .= "To: ".$to." <".$to.">".PHP_EOL; $naglowki .= "Content-Type: text/html; charset=utf-8".PHP_EOL; $naglowki .= "MIME-Version: 1.0".PHP_EOL; $naglowki .= "Content-Transfer-Encoding: 7bit".PHP_EOL; //$content=iconv("UTF-8","ISO-8859-2", $content.$footer); if ($message){ }else{ } } else { } ?>
oraz kod java script:
(function($){ $(document).ready(function() { $('#submit-form').click(function(e){ e.preventDefault(); var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var name = $('#rp_name').val(), email = $('#rp_email').val(), subject = $('#rp_subject').val(), message = $('#rp_message').val(), data_html, success = $('#success'); if(name == "") $('#rp_name').val('Prosimy, wpisz swoje imię'); if(subject == "") $('#rp_subject').val('Podaj temat wiadomości'); if(email == ""){ $('#rp_email').val('Uzupełnij adres e-mail'); }else if(reg.test(email) == false){ $('#rp_email').val('Niepoprawny adres e-mail'); } if(message == "") $('#rp_message').val('Wpisz treść wiadomości'); if(message != "" && name != "" && reg.test(email) != false) { data_html = "name=" + name + "&email="+ email + "&message=" + message + "&subject="+ subject; //alert(data_html); $.ajax({ type: 'POST', url: 'php_helpers/contact_form.php', data: data_html, success: function(msg){ if (msg == 'sent'){ success.html('<div class="alert alert-success">Wiadomość <strong> została wysłana!</strong> Dziękujemy!</div>') ; $('#rp_name').val(''); $('#rp_email').val(''); $('#rp_message').val(''); }else{ success.html('<div class="alert alert-error">Wiadomość <strong>nie została wysłana </strong> Spróbuj ponownie!</div>') ; } } }); } return false; }); }); })(jQuery);