邮件问题与PHP,无法发送 [英] Mail issues with PHP, Unable to send

查看:145
本文介绍了邮件问题与PHP,无法发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在我的网站上使用反馈表单,并且正在尝试将该反馈表单发送到我的电子邮件,但不断发出通知,或许有人可以发送正确的方式写信给我,感谢这么多,这里是我所有的代码和错误。

FORM

 <脚本类型= 文本/ JavaScript的 > 
函数MM_validateForm(){//v4.0
if(document.getElementById){
var i,p,q,nm,test,num,min,max,errors ='' ,ARGS = MM_validateForm.arguments; (i = 0; i<(args.length-2); i + = 3){test = args [i + 2]; VAL =的document.getElementById(参数[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 +'必须包含一个电子邮件地址。
} else if(test!='R'){num = parseFloat(val);
if(isNaN(val))errors + =' - '+ nm +'必须包含一个数字。
if(test.indexOf('inRange')!= -1){p = test.indexOf(':');
min = test.substring(8,p);最大= test.substring(P + 1);
if(num }}} else if(test.charAt(0)=='R')errors + =' - '+ nm +'is required.\\\
'; }
} if(errors)alert('发生以下错误:\ n'+ errors);
document.MM_returnValue =(errors =='');
}}
< / script>
< div id =services>
< h3>< a href =services.php>服务< / a>< / h3>
< p>我们可以做什么< / p>
< ul>
< li>项目< / li>
< li>项目< / li>
< li>项目< / li>
< li>项目< / li>
< / ul>
< / div>
< div id =portfolio>
< h3>< a href =portfolio.php>投资组合< / a>< / h3>
< p>我们的一些工作< / p>
< / div>
< div id =hireus>
< h3>< a href =services.php>在下方请求更多信息!< / a>< / h3>
< form action =processor.phpmethod =postname =myformid =myformonsubmit =MM_validateForm('fname','','R','lname',' ','R','email','','RisEmail','phone','','NisNum'); return document.MM_returnValue>
< label for =fname>名字< / label>
< input name =fnametype =textid =fname/>
< label for =lname>姓氏< / label>
< input name =lnametype =textid =lname/>
< label for =email>电子邮件地址< / label>
< input name =emailtype =textid =email/>
< label for =phone>电话号码< / label>
< input name =phonetype =textid =phoneplaceholder =800.867.5309/>
< fieldset class =checkgroup>
< legend>有兴趣的服务:< / legend>
< input name =servicestype =checkboxvalue =services_webid =services_web/>
< label for =services_web>网页设计< / label>
< input name =servicestype =checkboxvalue =services_designid =services_design/>
< label for =services_web>视频& 3D< /标签>
< input name =servicestype =checkboxvalue =services_consultationid =services_consultation/>
< label for =services_web> Consulation< / label>
< / fieldset>
< textarea name =commentsid =commentscols =35rows =3>< / textarea>
< input name =submittype =submitvalue =提交信息/>
< / form>

< / div>

处理器



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

* PHP表格处理器*
< * * ** * ** * *** /

  // Trim在strip_tags从输入中删除任何html,javascript等标签后删除空白
$ 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']));

//创建一个变量来格式化并保存所有输入
$ body =
网站联系表
名字:$ fname
Last名称:$ lname
电子邮件地址:$ email
电话:$ phone
有兴趣的服务:$ services
评论:$ 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 =stylesheettype =text / csshref =css / reset.css/>
< link rel =stylesheettype =text / csshref =css / formatBlog.css/>
< title> Schell Shock Design的作品集< / 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
//如果发送邮件,显示成功消息
echo'< div class =success> Thanks'。$ fname。'。您的邮件已发送。< / div>';
echo'< div class =success>您的表单结果副本也会邮寄到'。$ email。'。< / div>';
echo'< div class =success>我们会在24小时内以'。$ email。'或'。$ phone。'的形式回复您。< / div>';
?>

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

我的警告:

 警告:mail()[function.mail]:sendmail_from未在php.ini中设置或在C:\xampp\htdocs\schellshockdesign.com\中缺少自定义的From:头文件term5final \ finalproject \processor.php on line 24 

警告:mail()[function.mail]:sendmail_from未在php.ini中设置或者自定义From:头文件在C中缺失:\xampp\htdocs\schellshockdesign.com\term5final\finalproject\processor.php on line 25


解决方案

try

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


I am currently using a feed back form on my site and I am trying to get that feedback form to send to my email but keep getting notices maybe someone can send me the right way to write it thanks so much here is all my code and the errors..

FORM

    <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 Form Processor * *************/

//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>

My Warnings:

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

解决方案

try

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

这篇关于邮件问题与PHP,无法发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆