мой почтовый отправитель php не работает. Я сделал сообщение «succesfull» в HTML, которое нужно показать после успешной отправки почты. Теперь сообщение отображается правильно, но почта не поступает. Я пробовал разные пути к моему файлу php (./inc/.... Php;/inc/... .php; inc/.... Php), но это не помогло решить мою проблему. Это мой HTML:Форма не отправляет почту - PHP
<!-- form -->
<form name="contactForm" id="contactForm" method="post" action="inc/sendEmail.php">
\t \t \t <fieldset>
<div class="form-field">
\t \t \t \t \t \t <input name="contactName" type="text" id="contactName" placeholder="Név" value="" minlength="2" required="">
</div>
<div class="form-field">
\t \t \t \t <input name="contactEmail" type="email" id="contactEmail" placeholder="Email" value="" required="">
\t </div>
<div class="form-field">
\t \t \t \t \t <input name="contactSubject" type="text" id="contactSubject" placeholder="Tárgy" value="">
\t </div>
<div class="form-field">
\t \t <textarea name="contactMessage" id="contactMessage" placeholder="Üzenet" rows="10" cols="50" required=""></textarea>
\t </div>
<div class="form-field">
<button class="submitform">Küldés</button>
<div id="submit-loader">
<div class="text-loader">Küldés...</div>
\t \t \t \t <div class="s-loader">
\t \t \t \t \t \t \t \t \t <div class="bounce1"></div>
\t \t \t \t \t \t \t \t \t <div class="bounce2"></div>
\t \t \t \t \t \t \t \t \t <div class="bounce3"></div>
\t \t \t \t \t \t \t \t </div>
\t \t \t \t \t \t \t </div>
</div>
\t \t \t </fieldset>
\t \t </form> <!-- Form End -->
И это мой PHP:
<?php
$siteOwnersEmail = '[email protected]';
if($_POST) {
$name = trim(stripslashes($_POST['contactName']));
$email = trim(stripslashes($_POST['contactEmail']));
$subject = trim(stripslashes($_POST['contactSubject']));
$contact_message = trim(stripslashes($_POST['contactMessage']));
// Check Name
\t if (strlen($name) < 2) {
\t \t $error['name'] = "Name error msg";
\t }
\t // Check Email
\t if (!preg_match('/^[a-z0-9&\'\.\-_\+][email protected][a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
\t \t $error['email'] = "Email error msg";
\t }
\t // Check Message
\t if (strlen($contact_message) < 15) {
\t \t $error['message'] = "Message error msg";
\t }
// Subject
\t if ($subject == '') { $subject = "Contact Form Submission"; }
// Set Message
$message .= "Email from: " . $name . "<br />";
\t $message .= "Email address: " . $email . "<br />";
$message .= "Message: <br />";
$message .= $contact_message;
$message .= "<br /> ----- <br /> This email was sent from your site's contact form. <br />";
// Set From: header
$from = $name . " <" . $email . ">";
// Email Headers
\t $headers = "From: " . $from . "\r\n";
\t $headers .= "Reply-To: ". $email . "\r\n";
\t $headers .= "MIME-Version: 1.0\r\n";
\t $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (!$error) {
ini_set("sendmail_from", $siteOwnersEmail); // for windows server
$mail = mail($siteOwnersEmail, $subject, $message, $headers);
\t \t if ($mail) { echo "OK"; }
else { echo "Error message... :("; }
\t \t
\t } # end if - no validation error
\t else {
\t \t $response = (isset($error['name'])) ? $error['name'] . "<br /> \n" : null;
\t \t $response .= (isset($error['email'])) ? $error['email'] . "<br /> \n" : null;
\t \t $response .= (isset($error['message'])) ? $error['message'] . "<br />" : null;
\t \t
\t \t echo $response;
\t } # end if - there was a validation error
}
?>
Спасибо за Ваш комментарий! Я пробовал этот метод раньше, но сервер работает правильно. –