任何人都可以想到一个合乎逻辑的理由,为什么在我的123注册帐户上运行良好的联系表单不会对我的客户帐户有效?当我在我身边测试时,我会将电子邮件和表单内容完整地发送到我的收件箱,但是当我的客户帐户使用相同的代码时,他的电子邮件地址会收到一封没有数据的电子邮件。
<?php
$EmailFrom = "webmaster@pb.co.uk";
$EmailTo = "loans@website.co.uk";
$Subject = "Testing";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "eMail: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://website/thankyou.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
答案 0 :(得分:0)
更改
"From: $EmailFrom"
到
"From: $EmailFrom" . "\r\n"
答案 1 :(得分:0)
添加标题。
$Body = 'MIME-Version: 1.0' . "\r\n";
$Body .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$Body .= 'From: '. $EmailFrom . "\r\n" . 'X-Mailer: PHP/' . phpversion();