我目前正在我的網站上使用反饋表單,我正在嘗試將該反饋表單發送到我的電子郵件,但不斷收到通知,也許有人可以發送給我正確的寫信方式它非常感謝這裏全是我的代碼和錯誤..PHP發送郵件問題,無法發送
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表單處理器* * ** * ** * ** * ***/
//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 ("[email protected]","Widget Box Contact Form","$body","$email");
mail ("$email","Widget Box Contact Form","$body","[email protected]");
?>
<!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
請注意l內置PHP郵件功能的模仿。由於許多SMTP服務器被配置爲拒絕具有錯誤設置標題的電子郵件,因此很可能會遭受傳遞能力問題。我會研究一個爲PHPmailer處理這個問題的庫。 – DeaconDesperado 2012-07-07 18:55:00