我构建了2个联系表单(quote.php和contact.php),用jquery验证并提交给单独的ajax_contact.php和ajax_quote.php文件。它们都是基于我在其他网站上使用的相同模板构建的,但由于某种原因,ajax_contact.php返回此错误:
Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:Hosting5219056htmlajax_contact.php on line 41
我收到了自动回复邮件,但没有收到实际包含表单中提交的数据的电子邮件。
我真的很想知道这一点。一直试图用“ r n”和“ n”整天修复它,我认为会根据错误修复它,但我仍然在同一条船上。
这是ajax_contact.php:
// where is your config file stored?
include ("ajaxSubmit.php");
// CLIENT INFORMATION
$Firstname =3D $HTTP_POST_VARS['Firstname'];
$Lastname =3D $HTTP_POST_VARS['Lastname'];
$email =3D $HTTP_POST_VARS['email'];
$Business =3D $HTTP_POST_VARS['Business'];
$Address =3D $HTTP_POST_VARS['Address'];
$City =3D $HTTP_POST_VARS['City'];
$State =3D $HTTP_POST_VARS['State'];
$Zip =3D $HTTP_POST_VARS['Zip'];
$Phone =3D $HTTP_POST_VARS['Phone'];
$Fax =3D $HTTP_POST_VARS['Fax'];
$Comments =3D $HTTP_POST_VARS['Comments'];
// MODIFY THE FOLLOWING SECTION
// your name
$recipientname =3D "Company";
// your email
$recipientemail =3D "me@email.com";
// subject of the email sent to you
$subject =3D "Feedback for $recipientname";
// send an autoresponse to the user?
$autoresponse =3D "yes";
// subject of autoresponse
$autosubject =3D "Thank you for your mail!";
// autoresponse message
$automessage =3D "Thanks for the message.";
// thankyou displayed after the user clicks "submit"
$thanks =3D "Thank you for contacting us. We will get back to you as soon =
as possible.";
// END OF NECESSARY MODIFICATIONS
// format message
$message =3D "Online-Form Response for $recipientname:
Firstname: $Firstname
Lastname: $Lastname
Email: $email
Business: $Business
Address: $Address
City: $City
State: $State
Zip: $Zip
Phone: $Phone
Fax: $Fax
Comments: $Comments
";
// To send HTML mail, the Content-type header must be set
$headers =3D "MIME-Version: 1.0" . "rn";
$headers .=3D "Content-type: text/html; charset=3Diso-8859-1" . "rn";
// Additional headers
$headers .=3D "From: Company " . "=
rn";
$headers .=3D "Bcc: admin@email.com" . "rn";
// send mail and print success message
mail($recipientemail, $subject, $message, $headers);
echo "
w.location.href =3D "thanks_feedback.php";";
?
这是ajax_quote.php,它是同一个东西,只是为了一个不同的形式:
// where is your config file stored?
include ("ajaxSubmit.php");
// CLIENT INFORMATION
$Contactname = $HTTP_POST_VARS['Contactname'];
$email = $HTTP_POST_VARS['email'];
$Contacttitle = $HTTP_POST_VARS['Contacttitle'];
$Business = $HTTP_POST_VARS['Business'];
$Address = $HTTP_POST_VARS['Address'];
$State = $HTTP_POST_VARS['State'];
$Zip = $HTTP_POST_VARS['Zip'];
$Phone = $HTTP_POST_VARS['Phone'];
$Fax = $HTTP_POST_VARS['Fax'];
$product_desc = $HTTP_POST_VARS['product_desc'];
$sku = $HTTP_POST_VARS['sku'];
$annualturns = $HTTP_POST_VARS['annualturns'];
$seasonal = $HTTP_POST_VARS['seasonal'];
$minmaxpallet = $HTTP_POST_VARS['minmaxpallet'];
$avgpalletval = $HTTP_POST_VARS['avgpalletval'];
$avgpalletwt = $HTTP_POST_VARS['avgpalletwt'];
$maxpalletht = $HTTP_POST_VARS['maxpalletht'];
$casesperpallet = $HTTP_POST_VARS['casesperpallet'];
$unitweight = $HTTP_POST_VARS['unitweight'];
$reqlotnumctrl = $HTTP_POST_VARS['reqlotnumctrl'];
$freightclass = $HTTP_POST_VARS['freightclass'];
$hazardclass = $HTTP_POST_VARS['hazardclass'];
$barcodes = $HTTP_POST_VARS['barcodes'];
$avgupsfedex = $HTTP_POST_VARS['avgupsfedex'];
$avgorderweight = $HTTP_POST_VARS['avgorderweight'];
$ordersending = $HTTP_POST_VARS['ordersending'];
$custpickups = $HTTP_POST_VARS['custpickups'];
$flatfiles = $HTTP_POST_VARS['flatfiles'];
$shrinkwrap = $HTTP_POST_VARS['shrinkwrap'];
$repack = $HTTP_POST_VARS['repack'];
$specialreq = $HTTP_POST_VARS['specialreq'];
$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;
// MODIFY THE FOLLOWING SECTION
// your name
$recipientname = "Company";
// your email
$recipientemail = "me@email.com";
// subject of the email sent to you
$subject = "Quote Request for $recipientname";
// send an autoresponse to the user?
$autoresponse = "yes";
// subject of autoresponse
$autosubject = "Thank you for your mail!";
// autoresponse message
$automessage = "Thanks for the message. We've successfully received your quote request and will get back to you shortly.";
// thankyou displayed after the user clicks "submit"
$thanks = "Thank you for contacting us. We will get back to you as soon as possible.";
// END OF NECESSARY MODIFICATIONS
// format message
$message = "Online-Form Response for $recipientname:
Contact Name: $Contactname
Business: $Business
Email: $email
Address: $Address
State: $State
Zip: $Zip
Phone: $Phone
Fax: $Fax
--
Describe your product(s): $product_desc
How many SKU's (items): $sku
How many turns per year?: $annualturns
Are your products seasonal?: $seasonal
Indicate minimum and Maximum pallet levels: $minmaxpallet
Average value per pallet: $avgpalletval
Weight of a typical pallet: $avgpalletwt
Maximum pallet stacking height: $maxpalletht
Cases per pallet? Or average case size?: $casesperpallet
Weight of each unit?: $unitweight
Do you require lot number control?: $reqlotnumctrl
What freight class?: $freightclass
Is the product hazardous? If so, what classifications?: $hazardclass
--
Do you need custom Barcodes made?: $barcodes
What is the average number of orders shipped via UPS/Fedex?: $avgupsfedex
What is the average order size in weight?: $avgorderweight
What is the average number of lines per order?: $avgorderlines
Will your orders be sent via E-mail, FAX, or other?: $ordersending
Will you have customer pick ups, and how often?: $custpickups
Can your company e-mail us flat files?: $flatfiles
Do your orders need to be shrink wrapped?: $shrinkwrap
Do you need repackaging?: $repack
Are there any special requirements that your company may have?: $specialreq
-----------------------------
Browser: $browser
User IP: $ip";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
// Additional headers
$headers .= 'From: Company ' . "rn";
$headers .= 'Bcc: admin@email.com' . "rn";
// send mail and print success message
mail($recipientemail, $subject, $message, $headers);
if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($email,"$autosubject","$automessage","From: $recipientname ");
}
echo "";
?
这是ajaxSubmit.php,它做的不多:
/* VALIDATE HOW YOU NEED TO VALIDATE */
require_once('recaptchalib.php');
$privatekey = "******************************";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
$isValidate = true; // RETURN TRUE FROM VALIDATING, NO ERROR DETECTED
/* RETTURN ARRAY FROM YOUR VALIDATION */
/* THIS NEED TO BE IN YOUR FILE NO MATTERS WHAT */
if($isValidate == true){
echo "";
}else{
echo '{"jsonValidateReturn":'.json_encode($arrayError).'}'; // RETURN ARRAY WITH ERROR
}
?
编辑:我调查了一下,事实证明GoDaddy Windows托管(不是我的选择)不允许PHP邮件功能。所以我要么找到一个可行的解决方法(看起来那里有一些,似乎没有多少工作),或者我让他们切换到Linux主机(可能会修复它)。