0

我有一个可以在我的服务器上正常工作的电子邮件脚本,但是当我把它放在另一个服务器上时,我需要将服务器名称从 localhost 更改为他们拥有的名称。我拥有的电子邮件脚本没有服务器名称,我想知道该怎么做?下面是脚本...

<?PHP
$email = $_POST["emailaddress"];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$zipcode = $_POST["zipcode"];
$feedback = $_POST["feedback"];
$date=date("d-m-Y");

$to = "";
$subject = "New Feedback Received";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $email\n";

$message = "

<html>
<head></head>
<body>

A visitor to your website has left the following feedback; <br /><br />
Date: $date <br />
First Name: $firstname <br />
Last Name: $lastname <br />
Zip Code: $zipcode <br />
Email Address: $email <br />
Feedback: $feedback <br />

<img src=\"" />
</body>
</html>
";
$user = "$email";
$usersubject = "Thank You";

$userheaders = 'MIME-Version: 1.0' . "\r\n";
$userheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$userheaders .= "From: info@westmorelandberryfarm.com\n";
$usermessage =
"
<html>
<head></head>
<body>
Thank you for your feedback, your comments are important to us.
<br /><br />
We hope to see you at the Farm very soon!
<br /><br />
<br />
Tel:  <br />
<a href=\""</a><br />
<img src=\"" />
</body>
</html>
";

mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
$fh = fopen("feedback.txt", "a");
fwrite($fh, "Date:$date\r\nFirst Name:$firstname\r\nLast Name:$lastname\r\nEmail:$email\r\nZip   Code:$zipcode\r\nFeedback:$feedback\r\n \r\n");
fclose($fh);
?>
4

1 回答 1

0

如果您将它放在一个实时服务器环境中,例如Amazonor Rackspace,您将拥有一个合格的服务器名称,您可以从$_SERVER[]变量中获取该名称。但最重要的是您必须确保您的服务器实例有一个non-black listed ip,或分配一个弹性 ip 用于在所有域上传递邮件。

于 2012-10-25T09:08:33.477 回答