Мой код:Я не могу отправить почту в PHP
<?php
if(isset($_POST['submit'])){
//veryfing the name
if(empty($_POST['name'])){ ?>
<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>PLease enter your name .</div>
<?php}
else{
$name = htmlentities($_POST['name']);
}
//veryfing the email
if(empty($_POST['email'])) { ?>
<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>PLease enter your email .</div>
<?php}
else if(filter_var($_POST['email'] , FILTER_VALIDATE_EMAIL === false)){ ?>
<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>PLease enter a valid email .</div>
<?php }
else{
$email ="<". htmlentities($_POST['email']).">";
}
if(empty($_POST['message'])){?>
<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>PLease enter some message .</div>
<?php}
else{
$message = htmlentities($_POST['message']);
}
if(empty($_POST['name']) or empty($_POST['email']) or empty($_POST['message'])){?>
<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Something went wrong ! .</div>
<?php}
else{
$headers = 'From: {$email}' . "\r\n" .
'Reply-To: {$email}' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$send_mail = mail("[email protected]" , "An email from Omarmannan.net" , $message , $headers);
}
if(!$send_mail){?>
<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Something went wrong ! .</div>
<?php }
else{
echo '<div class="alert alert-success">Email successfully sent. Thank you for your message.</div>';
}
}?>
Но я не могу отправить почту. Я работаю со своим личным сайтом. На моей странице контакта я не могу отправить письмо с этим кодом. После нажатия кнопки «Отправить» отображается пустая страница.
Вы работаете на локальном хосте? – 2014-09-12 09:17:49
Пустая страница может быть вызвана тем, что ошибка вызывается, но отчет об ошибках отключен. – lxg
У вас есть [error_reporting] (http://de2.php.net/manual/en/function.error-reporting.php)? – AbcAeffchen