我的脚本无法发送电子邮件(再次)

时间:2015-10-04 08:09:17

标签: php

您好我使这个脚本无法发送电子邮件。我使用postfix(是的,我知道,但我想使用postfix)任何想法?它向我发送电子邮件但没有变量的内容。 谢谢你:

的index.html

    <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Portfolio</title>

<!-- Bootstrap -->
<link rel="stylesheet" href="css/bootstrap.css">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="container">
  <div class="row">
    <h2 align="center"> Whitelist Request Form </h2>
    <div class="col-lg-offset-3 col-xs-12 col-lg-6">
      <div class="jumbotron">
        <div class="row text-center">
          <div class="text-center col-xs-12 col-sm-12 col-md-12 col-lg-12"> </div>
          <div class="text-center col-lg-12"> 
            <!-- CONTACT FORM https://github.com/jonmbake/bootstrap3-contact-form -->
            <form role="form" id="feedbackForm" class="text-center" action="send_whitelist.php">
              <div class="form-group">
                <label for="name">Name</label>
                <input type="text" class="form-control" id="name" name="name" placeholder="Name">
                <span class="help-block" style="display: none;">Please enter your name.</span></div>
              <div class="form-group">
                <label for="email">E-Mail</label>
                <input type="email" class="form-control" id="email" name="email" placeholder="Email Address">
                <span class="help-block" style="display: none;">Please enter a valid e-mail address.</span></div>
              <div class="form-group">
                <label for="username">Username</label>
                 <input type="text" class="form-control" id="username" name="username" placeholder="Minecraft Username"></div>
                  <div class="form-group">
                  <label for="paysafe">Paysafe</label>
                <input type="number" class="form-control" id="paysafe" name="paysafe" placeholder="XXXX-XXXX-XXXX-XXXX">
                <span class="help-block" style="display: none;">Please enter a valid Paysafe number.</span></div>
              <button type="submit" id="submit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Send</button>
            </form>
            <!-- END CONTACT FORM --> 
          </div>
        </div>
      </div>
    </div>
  </div>
  </div>
<hr>
<footer class="text-center">
  <div class="container">
    <div class="row">
      <div class="col-xs-12">
        <p>Copyright © NickTehPro 2015. All rights reserved.</p>
      </div>
    </div>
  </div>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
<script src="js/jquery-1.11.2.min.js"></script> 
<!-- Include all compiled plugins (below), or include individual files as needed --> 
<script src="js/bootstrap.min.js"></script>
</body>
</html>

send_whitelist.php

    <?php
$username = $_POST['username'];
$name = $_POST['name'];
$paysafe = $_POST['paysafe'];
$email = $_POST['email'];

// Contact subject
$subject ="Minecraft Server Whitelist Request"; 

// Details
$message="Name: $name \nUsername: $username \nPaysafe: $paysafe  ";

// Mail of sender
$mail_from="$email"; 

// From 
$header="from: $name <$mail_from>";

// Enter your email address
$to ='nikospower1999@gmail.com';
$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email 
// display message "We've recived your information"
if($send_contact){
echo "<h2 align="center"> I have received your whitelist request. Please wait.</h2>";
}
else {
echo "ERROR";
}

?>

1 个答案:

答案 0 :(得分:2)

未设置表单method属性表单是通过GET提交的。 所以你应该设置method="post"

相关问题