dtp87205 2014-01-05 18:32
浏览 17

不使用MAIL功能接收客户端电子邮件地址

<html>
<head>
<title>Max Design contact page</title>
<link href="mdstyle1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">

<?php

$required = array("firstName" => "First Name", 
              "surname" => "Surname",
              "email" => "Email Address",
              "telephone" => "Telephone");

foreach($required as $field => $label) {
if (!$_POST[$field]) {
$warnings[$field] = "*";
}
}


if ($_POST["firstName"] &&
 !ereg("[a-zA-Z]", $_POST["firstName"]))
 $warnings["firstName"] = "Please check First Name for errors";

if ($_POST["surname"] &&
!ereg("[a-zA-Z]", $_POST["surname"]))
$warnings["surname"] = "Please check Surname for errors";

if ($_POST["email"] &&
!ereg("^[^@]+@([a-z\-]+\.)+[a-z]{2,4}$", $_POST["email"]))
$warnings["email"] = "Please check email for errors";

if ($_POST["telephone"] &&
!ereg("[0-9]", $_POST["telephone"]))
$warnings["telephone"] = "Please check Telephone for errors";


if (count($warnings) > 0) {

// sets the description of the sections of the form and must have an entry for each form         element
$description = array(); 
$description{"firstName"} = "First Name"; 
$description{"surname"} = "Surname"; 
$description{"telephone"} = "Telephone Number"; 
$description{"email"} = "Email Address"; 

?>


<div class="main-paragraph">

<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<br />
<div class="warnings"> * Please fill in these boxes </div>
<br />
<br />

<TABLE BORDER=0>
<TR>
<TD><label>First Name</label>
 </TD><TD><INPUT TYPE=TEXT SIZE=30 NAME="firstName"
    VALUE="<?php echo $_POST["firstName"];?>"></TD>
 <TD><div class="warnings"><?php echo $warnings["firstName"];?></div></TD>
</TR>

<TR>
<TD><label>Surname</label>
</TD><TD><INPUT TYPE=TEXT SIZE=30 NAME="surname"
    VALUE="<?php echo $_POST["surname"];?>"></TD>
 <TD><div class="warnings"><?php echo $warnings["surname"];?></div></TD>
</TR>

<TR>
<TD><label>Email Address</label>
</TD>
<TD><INPUT TYPE=TEXT SIZE=30 NAME="email"
         VALUE="<?php echo $_POST["email"];?>"></TD>
<TD><div class="warnings"><?php echo $warnings["email"];?></div></TD>
</TR>

<TR>
<TD><label>Telephone</label>
 </TD>
 <TD><INPUT TYPE=TEXT SIZE=15 NAME="telephone"
       VALUE="<?php echo $_POST["telephone"];?>"></TD>
 <TD><div class="warnings"><?php echo $warnings["telephone"];?></div></TD>
 </TR>

 </TABLE>
 <br />
 <INPUT TYPE=SUBMIT VALUE="Send Enquiry">

 </FORM>
 </div> <!-- end of main paragraph -->


 <?php
 }
 else  { // start of send section

 //stuff that goes to the enquirer
 $clients_email = "From: sales@rmrc.co.uk";
 $headers2 = "From: simon@maxdesign.org.uk"; 
 $subject2 = "Thank you for contacting MAX Design"; 
 $autoreply = "Thank you for contacting MAX Design. We will get back to you as soon as possible, 
           
 usualy within 48 hours. If you have any more questions, 
           
 please consult our website at www.maxdesign.org.uk/index";

 //prints out each field's title and contents in turn each on new line
 $body = "A quote request from the website:

"; 
 foreach($_POST as $description => $value)  {   
   $body .= sprintf("%s = %s
", $description, $value); 
   } 

 mail($email, $subject2, $autoreply, $headers2); 
 mail("sim.on@hotmail.co.uk", "MAX Design website enquiry", $body, $email); 
 header( "Location: http://www.maxdesign.org.uk/thank-you-for-quote-max-design.html" );

 } //end of send section

 ?>

</div><!--end of container/wrapper div -->
  </body>

  </html>

I am trying to send a fairly crudely formatted email (I am trying to get the email formatted a little bit using the $description variable but that isn't working either) from the clients website but the script won't send it to the clients email using the

$email
string so am having no luck. Have been at this for days now so any help really appreciated.

Simon

  • 写回答

1条回答 默认 最新

  • duankaolei2921 2014-01-05 18:37
    关注

    You are sending a variable called $email to your mail() which is not at all defined in the code. That is why your mail is not being sent. See below

    mail($email, $subject2, $autoreply, $headers2); 
        //^^^^^ Undefined variable
    

    Solution : Set the $email to some email.

    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程