Pona Monce
Новичок
- Регистрация
- 30.01.2018
- Сообщения
- 4
Доброго времени суток! Помогите разобраться, имеем код HTML и PHP, форма обратной связи, при заполнении и отправке формы выходит ошибка "Error sending email."
Что не так?(
Что не так?(
Код:
<section class="flat-row parallax parallax4" id="contact" style="background-position: 50% 177px;">
<div class="row-overlay"></div>
<div class="container">
<div class="row">
<div class="col-sm-5">
<div class="title-section style2">
<h1 class="title">Задайте свой вопрос?</h1>
<div class="p-section">
<p>
Наш менеджер с радостью ответит на все Ваши вопросы<br>и проконсультирует Вас по нужным Вам товарам и услугам.
</p>
</div>
</div>
</div>
<div class="col-sm-7">
<form action="contact-process.php" method="post" id="contactform" class="requestform" novalidate="novalidate">
<p class="author">
<label for="discuss">Чем мы можем помочь?</label>
<select name="discuss" id="discuss" required="required">
<option value="">Вопрос по продукции</option>
<option value="02">Вопрос по сотрудничеству</option>
<option value="03">Другой вопрос</option>
</select>
</p>
<p class="name">
<label for="name">Ваше Имя*</label>
<input id="name" name="name" type="text" aria-required="true" required="required">
</p>
<p class="phone">
<label for="discuss">Ваш номер телефона*</label>
<input id="phone" name="phone" type="text" value="" aria-required="true" required="required">
</p>
<p class="email">
<label for="discuss">Ваша электронная почта</label>
<input id="email" name="email" type="email" value="" aria-required="true" required="required">
</p>
<p class="form-submit">
<button class="flat-button bg-theme">Отправить</button>
</p>
</form>
</div>
</div>
</div>
</section>
Код:
<?php
$address = "webframe.ru@gmail.com";
if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
$error = false;
$fields = array( 'name', 'email', 'subject', 'message' );
foreach ( $fields as $field ) {
if ( empty($_POST[$field]) || trim($_POST[$field]) == '' )
$error = true;
}
if ( !$error ) {
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);
$e_subject = 'You\'ve been contacted by ' . $name . '.';
$e_body = "You have been contacted by: $name" . PHP_EOL . PHP_EOL;
$e_reply = "E-mail: $email" . PHP_EOL . PHP_EOL;
$e_subject = "\r\nsubject: $subject";
$e_content = "Message:\r\n$message" . PHP_EOL . PHP_EOL;
$msg = wordwrap( $e_body . $e_reply .$e_subject , 70 );
$headers = "From: $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
if(mail($address, $e_subject, $msg, $headers)) {
echo 'Success';
} else {
echo 'ERROR!';
}
}
?>