我之前使用的表单只是常规表单。您填写表格并点击提交,它将返回一个感谢页面。所以它从form.html到mailPage.php再到Thankyou.html。我现在两次使用这个相同的表格,它通常工作正常但由于某种原因在这个新网站上它没有发送电子邮件。我知道mailPage正在调用,因为它会将您发送到thankyou页面,但不会发送任何电子邮件。关于可能导致这种情况的任何想法。这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
<?php
$email = $_REQUEST['eMail'] ;
$comments = $_REQUEST['comments'] ;
$year = $_REQUEST['year'] ;
$make = $_REQUEST['make'] ;
$model= $_REQUEST['model'] ;
$zip = $_REQUEST['zip'] ;
$state = $_REQUEST['State'] ;
$city = $_REQUEST['City'] ;
$address = $_REQUEST['Address'] ;
$callTime = $_REQUEST['callTime'] ;
$workNumber= $_REQUEST['workNumber'] ;
$foundby = $_REQUEST['foundby'] ;
$fullName = $_REQUEST['fullName'] ;
$homeNumber = $_REQUEST['homeNumber'] ;
mail( "XXXX@XXXXXXXXXXX", "Estimate Request",
"From:\t$fullName\nEmail:\t$email\nHome Phone:\t$homeNumber\nWork Phone:\t$workNumber\nBest time to call:\t$callTime\nAddress:\n\t$address\n\t$city, $state $zip\nMake: $make\tModel:$model\tYear:$year\nFound us by:\t$foundby\n\nComments:\n$comments");
header( "Location: thankyou.html" );
?>
</body>
</html>
答案 0 :(得分:1)
唯一想到的是服务器上没有php邮件定义...比如exim4或其他东西。
答案 1 :(得分:1)
你的环境是什么?
它有邮件服务器吗?
请提供有关该事项的一些信息 所以我可以给你一个正确的答案。
像xampp这样的本地程序通常没有
邮件服务器已预先安装。
答案 2 :(得分:1)
我总是使用PHP中的PEAR来发送我的邮件,因为我对它正在做的事情有更多的控制权。它需要有以下两个名为:
的包含require "Mail.php";
require "Mail/mime.php";
我经常在这两条评论之后从我的表单中完成所有处理,然后我使用以下代码集合在一起:
$server = "mail.myserver.com";
$username = "myusername@myserver.com";
$password = "thisIsAPassword";
$port = "587";
// Set Up The Mail Headers
$hdrsUs = array(
"From" => $sender,
"To" => $receiverUs,
"Subject" => $subjectUs,
"Return-Path" => $sender
);
// Configure the Mailer Mechanism
$smtp = Mail::factory("smtp",
array(
"host" => $server,
"username" => $username,
"password" => $password,
"auth" => true,
"port" => $port
)
);
$textUs =
"This is a text version of the e-mail.";
$htmlUs =
"<html>
<body>
<center>
<b>This is the HTML version of the e-mail.</b>
</center>
</body>
</html>";
$mimeUs = new Mail_mime($crlf);
$mimeUs->setTXTBody($textUs);
$mimeUs->setHTMLBody($htmlUs);
// Do not EVER Try to Call These Lines in Reverse Order
$bodyUs = $mimeUs->get();
$hdrsUs = $mimeUs->headers($hdrsUs, true);
// Send the Message
$mailUs = $smtp->send($receiverUs, $hdrsUs, $bodyUs);
if (PEAR::isError($mailUs))
{
echo ($mailThem->getMessage());
}
else
{
echo " <br /><center><b>The Mail Has Sent.</b></center>\n";
}
答案 3 :(得分:0)
最常见的问题是电子邮件的输入名称会有所不同。你能不能做下面的事情? -
echo $email; die("");
如果您可以看到正确显示的电子邮件,则会与您服务器上的SMTP设置有关。