【问题标题】:Mail issues with PHP, Unable to sendPHP 的邮件问题,无法发送
【发布时间】:2012-07-07 18:47:03
【问题描述】:

我目前正在我的网站上使用反馈表,我正在尝试将该反馈表发送到我的电子邮件,但不断收到通知,也许有人可以向我发送正确的写作方式,非常感谢这里是我的全部代码和错误..

表格

    <script type="text/javascript">
    function MM_validateForm() { //v4.0
      if (document.getElementById){
        var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
        for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
          if (val) { nm=val.name; if ((val=val.value)!="") {
            if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
              if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
            } else if (test!='R') { num = parseFloat(val);
              if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
              if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
                min=test.substring(8,p); max=test.substring(p+1);
                if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
          } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
        } if (errors) alert('The following error(s) occurred:\n'+errors);
        document.MM_returnValue = (errors == '');
    } }
    </script>
            <div id="services">
              <h3><a href="services.php">Services</a></h3>
              <p>What we can do</p>
              <ul>
               <li>item</li>
               <li>item</li>
               <li>item</li>
               <li>item</li>
              </ul>
              </div>
            <div id="portfolio">
              <h3><a href="portfolio.php">Portfolio</a></h3>
                 <p>Some of our work</p>
            </div>
            <div id="hireus">
          <h3><a href="services.php">Request more info below!</a></h3>
          <form action="processor.php" method="post" name="myform" id="myform" onsubmit="MM_validateForm('fname','','R','lname','','R','email','','RisEmail','phone','','NisNum');return document.MM_returnValue">
        <label for="fname">First name</label>
        <input name="fname" type="text" id="fname" />
        <label for="lname">Last name</label>
        <input name="lname" type="text" id="lname" />
        <label for="email">Email Address</label>
        <input name="email" type="text" id="email" />
        <label for="phone">Phone Number</label>
        <input name="phone" type="text" id="phone" placeholder="800.867.5309" />
        <fieldset class="checkgroup">
        <legend>Services Interested In:</legend>
        <input name="services" type="checkbox" value="services_web" id="services_web" />
        <label for="services_web">Web Design</label>
         <input name="services" type="checkbox" value="services_design" id="services_design" />
        <label for="services_web">Video & 3D</label>
         <input name="services" type="checkbox" value="services_consultation" id="services_consultation" />
        <label for="services_web">Consulation</label>
        </fieldset>
        <textarea name="comments" id="comments" cols="35" rows="3"></textarea>
        <input name="submit" type="submit" value="Submit Info" />
        </form>

              </div>

 PROCESSOR 



<?php
/************************

*PHP 表单处理器 * *************/

//Trim removes white space after strip_tags gets rid of any html, javascript, etc tags from the input
$fname = trim(strip_tags($_POST['fname']));
$lname = trim(strip_tags($_POST['lname']));
$email = trim(strip_tags($_POST['email']));
$phone = trim(strip_tags($_POST['phone']));
$services = trim(strip_tags($_POST['services']));
$comments = trim(strip_tags($_POST['comments']));

//Creating a single variable to format and hold all the inputs
$body = "
Website Contact Form
First Name: $fname
Last Name: $lname
Email Address: $email
Phone: $phone
Services Interested In: $services
Comments: $comments";

mail ("spencer.schell87@gmail.com","Widget Box Contact Form","$body","$email");
mail ("$email","Widget Box Contact Form","$body","spencer.schell87@gmail.com");

?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/formatBlog.css" />
<title>Schell Shock Design's Portfolio</title>
</head>

<body class="tos">
  <div id="login">
   <?php include('login.php'); ?>
</div>
  </div>
  <div id="utilities">
   <?php include('utilities.php'); ?>
  </div>
<div id="container">
  <header>
    <?php include('header.php'); ?>
   </header>
 <div id="formsuccess">
            <h3>Thank You!</h3>
    <?php
//if the email was sent, show the success message
    echo '<div class="success">Thanks '.$fname.'. Your message was sent.</div>';
        echo '<div class="success">A copy of your form results were also mailed to '.$email.'.</div>';
    echo '<div class="success">We will get back to you at: '.$email.' or at: '.$phone.' within 24 hours.</div>';
?>

          </div>
  <div id="footer">
    <?php include('footer.php'); ?>
         </div>
</div>
</body>
</html>

我的警告:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\schellshockdesign.com\term5final\finalproject\processor.php on line 24

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\schellshockdesign.com\term5final\finalproject\processor.php on line 25

【问题讨论】:

  • 请注意内置 PHP 邮件功能的限制。由于许多 SMTP 服务器被配置为拒绝标头设置不正确的电子邮件,因此您很可能会遇到可传递性问题。我会研究一个像 PHPmailer 一样为你处理这个问题的库。

标签: php function email


【解决方案1】:

试试

mail ("spencer.schell87@gmail.com","Widget Box Contact Form","$body","From: $email");
mail ("$email","Widget Box Contact Form","$body","From: spencer.schell87@gmail.com");

【讨论】:

    【解决方案2】:

    你想设置一个 FROM Header... 因为错误 sais

    mail ("spencer.schell87@gmail.com","Widget Box Contact Form","$body","FROM: $email");
    mail ("$email","Widget Box Contact Form","$body","FROM: spencer.schell87@gmail.com");
    

    【讨论】:

    • 警告:mail() [function.mail]:无法在“localhost”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用 ini_set()在第 24 行的 C:\xampp\htdocs\schellshockdesign.com\term5final\finalproject\processor.php 警告:mail() [function.mail]:无法在“localhost”端口 25 连接到邮件服务器,请验证您的“SMTP”和 php.ini 中的“smtp_port”设置或在第 25 行的 C:\xampp\htdocs\schellshockdesign.com\term5final\finalproject\processor.php 中使用 ini_set()
    • 修复了第一部分,但是这可能是因为我使用的是 Xampp 还是什么,如果我上传到我的网站,它会工作还是不工作....
    • Xampp 不包括服务器邮件。您将不得不安装另一个服务。在您的服务器上,您不会有任何问题。
    猜你喜欢
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多