2010-01-16 293 views
0

我已經構建了2個聯繫表單(quote.php和contact.php),並使用jquery進行了驗證,並使用它提交以分開ajax_contact.php和ajax_quote.php文件。他們倆都建立在我在其他網站使用相同的模板,但由於某些原因,ajax_contact.php將返回該錯誤:SMTP服務器響應:451

Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5219056\html\ajax_contact.php on line 41 

我得到的自動回覆郵件,而不是電子郵件它實際上包含在表單中提交的數據。

我真的在我的智慧結束與此。一直試圖用「\ r \ n」和「\ n」來修復它,我認爲它會根據錯誤修復它,但我仍然在同一條船上。

這裏是ajax_contact.php:

<?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 "[email protected]"; 

// 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: 
<br> 
Firstname: $Firstname 
<br> 
Lastname: $Lastname 
<br> 
Email: $email 
<br> 
Business: $Business 
<br> 
Address: $Address 
<br> 
City: $City 
<br> 
State: $State 
<br> 
Zip: $Zip 
<br> 
Phone: $Phone 
<br> 
Fax: $Fax 
<br> 
Comments: $Comments 
<br> 
"; 

// To send HTML mail, the Content-type header must be set 
$headers =3D "MIME-Version: 1.0" . "\r\n"; 
$headers .=3D "Content-type: text/html; charset=3Diso-8859-1" . "\r\n"; 

// Additional headers 
$headers .=3D "From: Company <[email protected]>" . "= 
\r\n"; 
$headers .=3D "Bcc: [email protected]" . "\r\n"; 

// send mail and print success message 
mail($recipientemail, $subject, $message, $headers); 

    echo "<script language=3D\"JavaScript\" type=3D\"text/JavaScript\"> windo= 
w.location.href =3D \"thanks_feedback.php\";</script>"; 

? 

這裏是ajax_quote.php,這是同樣的事情,只是以不同的形式:

<?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 = "[email protected]"; 

// 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: 
<br> 
Contact Name: $Contactname 
<br> 
Business: $Business 
<br> 
Email: $email 
<br> 
Address: $Address 
<br> 
State: $State 
<br> 
Zip: $Zip 
<br> 
Phone: $Phone 
<br> 
Fax: $Fax 
<br> 
-- 
<br> 
Describe your product(s): $product_desc 
<br> 
How many SKU's (items): $sku 
<br> 
How many turns per year?: $annualturns 
<br> 
Are your products seasonal?: $seasonal 
<br> 
Indicate minimum and Maximum pallet levels: $minmaxpallet 
<br> 
Average value per pallet: $avgpalletval 
<br> 
Weight of a typical pallet: $avgpalletwt 
<br> 
Maximum pallet stacking height: $maxpalletht 
<br> 
Cases per pallet? Or average case size?: $casesperpallet 
<br> 
Weight of each unit?: $unitweight 
<br> 
Do you require lot number control?: $reqlotnumctrl 
<br> 
What freight class?: $freightclass 
<br> 
Is the product hazardous? If so, what classifications?: $hazardclass 
<br> 
-- 
<br> 
Do you need custom Barcodes made?: $barcodes 
<br> 
What is the average number of orders shipped via UPS/Fedex?: $avgupsfedex 
<br> 
What is the average order size in weight?: $avgorderweight 
<br> 
What is the average number of lines per order?: $avgorderlines 
<br> 
Will your orders be sent via E-mail, FAX, or other?: $ordersending 
<br> 
Will you have customer pick ups, and how often?: $custpickups 
<br> 
Can your company e-mail us flat files?: $flatfiles 
<br> 
Do your orders need to be shrink wrapped?: $shrinkwrap 
<br> 
Do you need repackaging?: $repack 
<br> 
Are there any special requirements that your company may have?: $specialreq 
<br> 
----------------------------- 
<br> 
Browser: $browser 
<br> 
User IP: $ip"; 

// To send HTML mail, the Content-type header must be set 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

// Additional headers 
$headers .= 'From: Company <[email protected]>' . "\r\n"; 
$headers .= 'Bcc: [email protected]' . "\r\n"; 

// 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 <$recipientemail>"); 
} 

    echo "<script language=\"JavaScript\" type=\"text/JavaScript\"> window.location.href = \"thanks_quote.php\";</script>"; 

? 

這裏是ajaxSubmit.php,它沒有按做的不多:

<?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窗口託管(N OT我的選擇)不允許PHP郵件功能。所以我要麼找到一個可行的解決方法(看起來好像有幾個,似乎沒有多少工作),或者我讓他們切換到Linux託管(可能會解決這個問題)。

+1

請問,如果你不使用任何自定義頁眉工作? – 2010-01-16 00:33:01

回答

2

不僅在標題中,而且在正文中使用\ r \ n。 由於您使用文件中的換行符,因此可以在您使用的代碼編輯器中進行設置。

+0

我試過了,但也許我做得不對。 LF應該在正文消息的每個換行符之後進行嗎? – miles 2010-01-21 14:31:34

+0

從服務器對你的答案看來,你需要使用另一個換行符,而不是隻使用LF。嘗試\ r \ n – kirilloid 2010-01-21 19:43:33

0

什麼是所有那些3D的代碼? $ variable =

$recipientname =3D "Company"; 
+0

yikes,我不知道。自從我問這個問題已經有一段時間了。我甚至不記得我在做什麼。 : -/ – miles 2011-02-28 20:32:14

+0

嘿,是的,這是一個相當古老的線程。它由於某種原因彈出在首頁上。你在做什麼,我認爲這會是問題:-) – 2011-02-28 20:43:02

-2

剛剛看到你的編輯 - 想把PostageApp扔在你的方向。它不使用PHP mail()函數,但是如果您已經使用當前設置的mail()函數編寫了所有內容,則只需進行微小的更改。

看一看,讓我知道如果您有任何問題!

披露:我PostageApp的產品經理!)