接触表现形式的消息,但没有电子邮件

问题描述:

我建立了一个接触的形式,但问题是,有时它发出的消息,有时不会,我添加了一个搜索栏的网站,并称呼该输入不同的提交按钮,可以那是干涉?接触表现形式的消息,但没有电子邮件

这是代码。

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$message = $_POST['message']; 
$from = 'From: [email protected]'; 
$to = '[email protected]'; 
$subject = 'Contact formulier bericht'; 
$human = $_POST['human']; 

$headers = "From: [email protected]\r\n"; 
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n"; 
$headers .= "CC: [email protected]\r\n"; 
$headers .= 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

$body = '<!DOCTYPE html> 
<html> 
    <head> 
<style type="text/css"> 
    body 
     {background: #fff; 
    width:100%; 
    height:auto; 
    margin: 0;} 
    #header-mail{background:#110f10; 
    width:650px; 
    height:70px; 
    margin: 0 auto;} 
    #content{background:#fff; 
    width:630px; 
    height:auto; 
    padding: 20px; 
    word-wrap:break-word; 
    margin: 0 auto;} 
    .mail-text{font-family:arial; 
    color:#808080; 
    font-size:12pt; 
    line-height:130%; 
    margin: 0 auto; 
    text-align: left;} 
    .bold{font-family:arial; 
    color:#1f669a; 
    font-size:14pt; 
    font-weight:bold; 
    margin: 0 auto; 
    text-align: left;} 
</style> 
    </head> 
<body> 
    <center> 
<img src="http://k2stuc.nl/img/bg-mailer.jpg" alt="Header" /> 
<div id="content"> 
     <p class="bold">'.$name.'<br>'.$email.'</p><br> 
     <p class="mail-text">'.nl2br($message).'</p> 
</div> 
<a href="http://www.k2stuc.nl"> 
<img src="http://k2stuc.nl/img/mailer-footer.jpg" alt="Footer" /> 
</a> 
    </center> 
</body> 
</html>'; 
if ($_POST['submit']) { 
if ($name != '' && $email != '') { 
if ($human == '4') {     
if (mail ($to, $subject, $body, $headers)) { 
echo '<p class="correct-message">Uw bericht is succesvol verzonden!</p>'; 
} else { 
echo '<p class="correct-message">Er is iets verkeerd gegaan, probeer het nog eens!</p>'; 
} 
} else if ($_POST['submit'] && $human != '4') { 
echo '<p class="correct-message">U heeft de veiligheidsvraag verkeerd beantwoord!</p>'; 
} 
} else { 
echo '<p class="correct-message">U heeft niet alle verplichte velden ingevuld!</p>'; 
} 
} 
?> 

     <form method="post" action="contact.php"> 

      <label>Naam</label> 
      <input name="name" placeholder="Type hier"> 

      <label>Email</label> 
      <input name="email" type="email" placeholder="Type hier"> 

      <label>Bericht</label> 
      <textarea name="message" placeholder="Type hier"></textarea> 

      <label>Hoeveel is 2+2?</label> 
      <input name="human" placeholder="Type hier"> 

      <input id="submit" name="submit" type="submit" value="Verzend"> 

     </form> 
+0

你有没有看垃圾邮件箱? – hlegius 2013-03-21 00:00:42

+0

是的,那不是它a.lready检查它,完全地随机 – 2013-03-21 00:07:06

+0

尝试改变单引号双引号'$身体=“'和'

试试看。我评论了几行。在用我自己的电子邮件进行测试后,我发送了10封包含以下代码的测试邮件,并收到了所有邮件。

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$message = $_POST['message']; 
// $from = 'From: [email protected]'; // COMMENTED OUT - conflicting 
$to = '[email protected]'; 
$subject = 'Contact formulier bericht'; 
$human = $_POST['human']; 

$headers = "From: [email protected]\r\n"; 
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n"; 
// $headers .= "CC: [email protected]\r\n"; // Commented out for testing. May be a problem 
$headers .= 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

$body = '<!DOCTYPE html> 
<html> 
<head> 
<style type="text/css"> 
body{background: #fff; 
width:100%; 
height:auto; 
margin: 0;} 
#header-mail{background:#110f10; 
width:650px; 
height:70px; 
margin: 0 auto;} 
#content{background:#fff; 
width:630px; 
height:auto; 
padding: 20px; 
word-wrap:break-word; 
margin: 0 auto;} 
.mail-text{font-family:arial; 
color:#808080; 
font-size:12pt; 
line-height:130%; 
margin: 0 auto; 
text-align: left;} 
.bold{font-family:arial; 
color:#1f669a; 
font-size:14pt; 
font-weight:bold; 
margin: 0 auto; 
text-align: left;} 
</style> 
</head> 
<body> 
<center> 
<img src="http://k2stuc.nl/img/bg-mailer.jpg" alt="Header" /> 
<div id="content"><p class="bold">'.$name.'<br>'.$email.'</p><br><p class="mail-text"> 
'.nl2br($message).'</p> 
</div> 
<a href="http://www.k2stuc.nl"> 
<img src="http://k2stuc.nl/img/mailer-footer.jpg" alt="Footer" /> 
</a> 
</center> 
</body> 
</html>'; 

if ($_POST['submit']) { 
if ($name != '' && $email != '') { 
if ($human == '4') {     
if (mail ($to, $subject, $body, $headers)) { 
echo '<p class="correct-message">Uw bericht is succesvol verzonden!</p>'; 
} else { 
echo '<p class="correct-message">Er is iets verkeerd gegaan, probeer het nog eens!</p>'; 
} 
} else if ($_POST['submit'] && $human != '4') { 
echo '<p class="correct-message">U heeft de veiligheidsvraag verkeerd beantwoord!</p>'; 
} 
} else { 
echo '<p class="correct-message">U heeft niet alle verplichte velden ingevuld!</p>'; 
} 
} 
?>