Windows 主机上的 php 联系表单错误

发布于 2024-09-14 05:31:30 字数 2131 浏览 4 评论 0原文

我正在尝试在 widows asp.net 托管包上使用 php 联系表单,已启用 php,但我的表单仍然没有发送电子邮件,而是指向 error.html 页面……

这是代码

<?php

$EmailFrom = "anksaltlamps.com";
$EmailTo = "[email protected]";
$Subject = "Website Query";
$Name = "Not Specified";
$Tel= "Not Specified";
$City= "Not Specified";
$Country= "Not Specified";
$Other= "Not Specified";
$Address= "Not Specified";
$Message= "Not Specified";
$State= "Not Specified";


$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Country = Trim(stripslashes($_POST['Country']));
$Other = Trim(stripslashes($_POST['Other']));
$Address = Trim(stripslashes($_POST['Address'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";

$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";

$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";

$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";

$Body .= "City: ";
$Body .= $City;
$Body .= "\n";

$Body .= "State/Province: ";
$Body .= $State;
$Body .= "\n";

$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";

$Body .= "Other Country: ";
$Body .= $Other;
$Body .= "\n";

$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

ini_set('sendmail_from', '[email protected]');
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

,或者您检查一下通过此链接在线

链接文本

I am trying to use a php contact form on widows asp.net hosting package, php is enabled but still my form is not sending email it is directing to error.html page......

here is the code

<?php

$EmailFrom = "anksaltlamps.com";
$EmailTo = "[email protected]";
$Subject = "Website Query";
$Name = "Not Specified";
$Tel= "Not Specified";
$City= "Not Specified";
$Country= "Not Specified";
$Other= "Not Specified";
$Address= "Not Specified";
$Message= "Not Specified";
$State= "Not Specified";


$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Country = Trim(stripslashes($_POST['Country']));
$Other = Trim(stripslashes($_POST['Other']));
$Address = Trim(stripslashes($_POST['Address'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";

$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";

$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";

$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";

$Body .= "City: ";
$Body .= $City;
$Body .= "\n";

$Body .= "State/Province: ";
$Body .= $State;
$Body .= "\n";

$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";

$Body .= "Other Country: ";
$Body .= $Other;
$Body .= "\n";

$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

ini_set('sendmail_from', '[email protected]');
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

or you check it online by this link

link text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必你懂 2024-09-21 05:31:30

阅读本文
这可能是由于您在 php.ini 中的邮件设置造成的。

Read this.
This is probably due to your mail settings in php.ini.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文