【问题标题】:SMTP server response: 451SMTP 服务器响应:451
【发布时间】:2010-01-16 00:12:40
【问题描述】:

我已经构建了 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:\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 "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:
<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 <info@company.com>" . "=
\r\n";
$headers .=3D "Bcc: admin@email.com" . "\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 = "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:
<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 <info@company.com>' . "\r\n";
$headers .= 'Bcc: admin@email.com' . "\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 Windows 托管(不是我的选择)不允许 PHP 邮件功能。所以我要么找到一个可行的解决方法(看起来有几个,似乎没有多少工作),或者我让他们切换到 Linux 托管(这可能会解决它)。

【问题讨论】:

  • 不使用任何自定义标头是否有效?

标签: php ajax email forms smtp


【解决方案1】:

不仅在标题中使用 \r\n,而且在正文中使用。 由于您使用文件中的换行符,因此您可以在您使用的代码编辑器中设置它。

【讨论】:

  • 我试过了,但也许我做得不对。 LF 应该在正文消息中的每个换行符之后进行吗?
  • 从服务器对您的回答看来,您似乎需要使用另一个换行符,而不仅仅是 LF。试试\r\n
【解决方案2】:

代码中的所有3D 是什么?就在 $variable =

之后
$recipientname =3D "Company";

【讨论】:

  • 哎呀,我不知道。我问这个已经有一段时间了。我什至不记得我在做什么。 :-/
  • 嘿,是的,这是一个相当古老的线程。由于某种原因,它突然出现在首页。无论你在做什么,我认为那将是问题:-)
【解决方案3】:

刚刚看到你的编辑 - 想把 PostageApp 扔向你的方向。它不使用 PHP 的 mail() 函数,但如果您在当前设置下使用 mail() 函数编写了所有内容,则只需进行微小的更改。

看看吧,如果有任何问题,请告诉我!

全面披露:我是 PostageApp 的产品经理!)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-16
    • 1970-01-01
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 2019-09-02
    • 2014-03-30
    • 2012-04-16
    相关资源
    最近更新 更多